When attempting to rename a file using sftp subsystem, it will always
fail with "No such file", as the request rename(newfile, newfile) will
be sent, even though "lftp -d" will print the correct information;

The bug happens due to the fact that WirePath can return the
same pointer for different calls (because of lc_to_utf8):

SFtp.cc:
     SendRequest(new Request_RENAME(WirePath(file),WirePath(file1),
            SSH_FXF_RENAME_NATIVE,protocol_version),Expect::DEFAULT);


const char *SFtp::WirePath(const char *path)
{
   path=dir_file(cwd,path);
   if(!use_full_path || path[0]=='~')
      path=SkipHome(path);
   LogNote(9,"path on wire is `%s'",path);
   return lc_to_utf8(path);
}

const char *SFtp::lc_to_utf8(const char *s)
{
-   if(!send_translate || !s)
-      return s;
+   if(!s)
+      return s;
+
+   if(!send_translate)
+     return xstring::get_tmp(s);

   send_translate->ResetTranslation();
   send_translate->PutTranslated(s);
   send_translate->Buffer::Put("",1);
   int len;
   send_translate->Get(&s,&len);
   send_translate->Skip(len);
   return xstring::get_tmp(s,len);
}



Cheers,

Einar Lielmanis

Reply via email to