Bug 168011

Summary: Renaming in FTP overwrites existing files without confirmation on platforms without or turned off size command
Product: [Frameworks and Libraries] frameworks-kio Reporter: D. Schwartzkopff <dsk1>
Component: FTPAssignee: David Faure <faure>
Status: REPORTED ---    
Severity: normal CC: asn, kdelibs-bugs, nate, Vdragon.Taiwan
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description D. Schwartzkopff 2008-08-01 17:43:33 UTC
Version:            (using KDE 3.5.9)
Installed from:    SuSE RPMs
OS:                Linux

Sorry, bug 127793 is not fixed for all ftp servers. I am using z/OS 1.8 (IBM mainframe) with default configuration. If I try to rename a file to an existing one the following conversation happens:
Request: SIZE /home/user/x
Response: 501 command aborted -- FTP server not configured for SIZE
Request: cwd /home/user/x
Response: 550 CWD cmd failed : EDC5135I Not a directory. (errno2=0x0519004F)
Request: RNFR x_1
Response: 350 RNFR accepted. Please supply new name for RNTO.
Request: RNTO /home/user/x
Response: 250 /home/user/x_1 renamed to /home/user/x 


I changed the source of ftp.cc/ftp.cpp to fix this:

bool Ftp::ftpFileExists(const QString& path)
{
  QCString buf;
  buf = "RNFR ";
  buf += remoteEncoding()->encode(path);
  if( !ftpSendCmd( buf ) || (m_iRespCode != 350) )
  return false;

  // skip leading "550 " (response code)
  const char* psz = ftpResponse(4);
  return psz != 0;
}
Comment 1 V字龍(Vdragon) 2013-10-19 19:07:12 UTC
I can confirm the same issue(file ovewrite), however I don't know the server supports size command or not.
Comment 2 Justin Zobel 2022-11-30 05:28:17 UTC
Thank you for reporting this issue in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "REPORTED" when replying. Thank you!
Comment 3 D. Schwartzkopff 2022-12-08 16:38:52 UTC
The problem existed (or exists) because the server was configured to not accept the SIZE command. This is not the case at the moment, so it will take some time to change that and test konqueror afterwards.
Comment 4 D. Schwartzkopff 2022-12-20 13:37:30 UTC
Sorry for the long wait.
I've tested this issue and (even with KDE 5 and openSUSE 15.4) the error still exists and every file would be overwritten without warning if you are renaming a file to an already existing one. (The FTP server issues the message "501 command aborted -- FTP server not configured for SIZE.)
Comment 5 D. Schwartzkopff 2022-12-20 14:37:29 UTC
Sorry, forgot the status change.