[BACK]Return to sftp-server.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sftp-server.c between version 1.12 and 1.13

version 1.12, 2001/01/15 21:46:38 version 1.13, 2001/01/16 20:54:27
Line 183 
Line 183 
         }          }
 }  }
   
 Attrib *  void
 stat_to_attrib(struct stat *st)  stat_to_attrib(struct stat *st, Attrib *a)
 {  {
         static Attrib a;          attrib_clear(a);
         attrib_clear(&a);          a->flags = 0;
         a.flags = 0;          a->flags |= SSH2_FILEXFER_ATTR_SIZE;
         a.flags |= SSH2_FILEXFER_ATTR_SIZE;          a->size = st->st_size;
         a.size = st->st_size;          a->flags |= SSH2_FILEXFER_ATTR_UIDGID;
         a.flags |= SSH2_FILEXFER_ATTR_UIDGID;          a->uid = st->st_uid;
         a.uid = st->st_uid;          a->gid = st->st_gid;
         a.gid = st->st_gid;          a->flags |= SSH2_FILEXFER_ATTR_PERMISSIONS;
         a.flags |= SSH2_FILEXFER_ATTR_PERMISSIONS;          a->perm = st->st_mode;
         a.perm = st->st_mode;          a->flags |= SSH2_FILEXFER_ATTR_ACMODTIME;
         a.flags |= SSH2_FILEXFER_ATTR_ACMODTIME;          a->atime = st->st_atime;
         a.atime = st->st_atime;          a->mtime = st->st_mtime;
         a.mtime = st->st_mtime;  
         return &a;  
 }  }
   
 Attrib *  Attrib *
Line 258 
Line 256 
 int  int
 handle_to_string(int handle, char **stringp, int *hlenp)  handle_to_string(int handle, char **stringp, int *hlenp)
 {  {
         char buf[1024];  
         if (stringp == NULL || hlenp == NULL)          if (stringp == NULL || hlenp == NULL)
                 return -1;                  return -1;
         snprintf(buf, sizeof buf, "%d", handle);          *stringp = xmalloc(sizeof(int32_t));
         *stringp = xstrdup(buf);          PUT_32BIT(*stringp, handle);
         *hlenp = strlen(*stringp);          *hlenp = sizeof(int32_t);
         return 0;          return 0;
 }  }
   
 int  int
 handle_from_string(char *handle, u_int hlen)  handle_from_string(char *handle, u_int hlen)
 {  {
 /* XXX OVERFLOW ? */          int val;
         char *ep;          if (hlen != sizeof(int32_t))
         long lval = strtol(handle, &ep, 10);  
         int val = lval;  
         if (*ep != '\0')  
                 return -1;                  return -1;
           val = GET_32BIT(handle);
         if (handle_is_ok(val, HANDLE_FILE) ||          if (handle_is_ok(val, HANDLE_FILE) ||
             handle_is_ok(val, HANDLE_DIR))              handle_is_ok(val, HANDLE_DIR))
                 return val;                  return val;
Line 562 
Line 557 
 void  void
 process_do_stat(int do_lstat)  process_do_stat(int do_lstat)
 {  {
         Attrib *a;          Attrib a;
         struct stat st;          struct stat st;
         u_int32_t id;          u_int32_t id;
         char *name;          char *name;
Line 575 
Line 570 
         if (ret < 0) {          if (ret < 0) {
                 status = errno_to_portable(errno);                  status = errno_to_portable(errno);
         } else {          } else {
                 a = stat_to_attrib(&st);                  stat_to_attrib(&st, &a);
                 send_attrib(id, a);                  send_attrib(id, &a);
                 status = SSH2_FX_OK;                  status = SSH2_FX_OK;
         }          }
         if (status != SSH2_FX_OK)          if (status != SSH2_FX_OK)
Line 599 
Line 594 
 void  void
 process_fstat(void)  process_fstat(void)
 {  {
         Attrib *a;          Attrib a;
         struct stat st;          struct stat st;
         u_int32_t id;          u_int32_t id;
         int fd, ret, handle, status = SSH2_FX_FAILURE;          int fd, ret, handle, status = SSH2_FX_FAILURE;
Line 613 
Line 608 
                 if (ret < 0) {                  if (ret < 0) {
                         status = errno_to_portable(errno);                          status = errno_to_portable(errno);
                 } else {                  } else {
                         a = stat_to_attrib(&st);                          stat_to_attrib(&st, &a);
                         send_attrib(id, a);                          send_attrib(id, &a);
                         status = SSH2_FX_OK;                          status = SSH2_FX_OK;
                 }                  }
         }          }
Line 775 
Line 770 
         if (dirp == NULL || path == NULL) {          if (dirp == NULL || path == NULL) {
                 send_status(id, SSH2_FX_FAILURE);                  send_status(id, SSH2_FX_FAILURE);
         } else {          } else {
                 Attrib *a;  
                 struct stat st;                  struct stat st;
                 char pathname[1024];                  char pathname[1024];
                 Stat *stats;                  Stat *stats;
Line 791 
Line 785 
                             "%s/%s", path, dp->d_name);                              "%s/%s", path, dp->d_name);
                         if (lstat(pathname, &st) < 0)                          if (lstat(pathname, &st) < 0)
                                 continue;                                  continue;
                         a = stat_to_attrib(&st);                          stat_to_attrib(&st, &(stats[count].attrib));
                         stats[count].attrib = *a;  
                         stats[count].name = xstrdup(dp->d_name);                          stats[count].name = xstrdup(dp->d_name);
                         stats[count].long_name = ls_file(dp->d_name, &st);                          stats[count].long_name = ls_file(dp->d_name, &st);
                         count++;                          count++;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13