[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.38 and 1.39

version 1.38, 2002/09/11 22:41:50 version 1.39, 2003/02/06 09:29:18
Line 812 
Line 812 
 process_rename(void)  process_rename(void)
 {  {
         u_int32_t id;          u_int32_t id;
         struct stat st;  
         char *oldpath, *newpath;          char *oldpath, *newpath;
         int ret, status = SSH2_FX_FAILURE;          int status;
   
         id = get_int();          id = get_int();
         oldpath = get_string(NULL);          oldpath = get_string(NULL);
         newpath = get_string(NULL);          newpath = get_string(NULL);
         TRACE("rename id %u old %s new %s", id, oldpath, newpath);          TRACE("rename id %u old %s new %s", id, oldpath, newpath);
         /* fail if 'newpath' exists */          /* fail if 'newpath' exists */
         if (stat(newpath, &st) == -1) {          if (link(oldpath, newpath) == -1)
                 ret = rename(oldpath, newpath);                  status = errno_to_portable(errno);
                 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;          else if (unlink(oldpath) == -1) {
         }                  status = errno_to_portable(errno);
                   /* clean spare link */
                   unlink(newpath);
           } else
                   status = SSH2_FX_OK;
         send_status(id, status);          send_status(id, status);
         xfree(oldpath);          xfree(oldpath);
         xfree(newpath);          xfree(newpath);
Line 858 
Line 861 
 process_symlink(void)  process_symlink(void)
 {  {
         u_int32_t id;          u_int32_t id;
         struct stat st;  
         char *oldpath, *newpath;          char *oldpath, *newpath;
         int ret, status = SSH2_FX_FAILURE;          int ret, status;
   
         id = get_int();          id = get_int();
         oldpath = get_string(NULL);          oldpath = get_string(NULL);
         newpath = get_string(NULL);          newpath = get_string(NULL);
         TRACE("symlink id %u old %s new %s", id, oldpath, newpath);          TRACE("symlink id %u old %s new %s", id, oldpath, newpath);
         /* fail if 'newpath' exists */          /* this will fail if 'newpath' exists */
         if (stat(newpath, &st) == -1) {          ret = symlink(oldpath, newpath);
                 ret = symlink(oldpath, newpath);          status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
                 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;  
         }  
         send_status(id, status);          send_status(id, status);
         xfree(oldpath);          xfree(oldpath);
         xfree(newpath);          xfree(newpath);

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39