Bug 144989

Summary: infinity recursive CWD in FXP transfer
Product: [Applications] kftpgrabber Reporter: Nomadic <nomadeku>
Component: generalAssignee: Jernej Kos <kostko>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Nomadic 2007-05-03 17:06:38 UTC
Version:           0.8.1 (using KDE KDE 3.5.6)
Installed from:    Unlisted Binary Package
Compiler:          gcc 4.1.2 ../gcc-4.1.2/configure --prefix=/usr --enable-shared --enable-languages=c,c++,objc --enable-threads=posix --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu
OS:                Linux

connection: 
glftpd [TLS] ---FXP---> glftpd [TLS]

in transfered directory there is a catalogue [Complete] with permission denied (need only for display of the upload status) and being in the skiplist with skip when queuing

on start transfer kftpgrabber tries to make such:
CWD /dir
250 CWD command successful.
CWD /dir/[Complete]
550 - permission denied
CWD /dir/[Complete]/[Complete]
550 - permission denied
CWD /dir/[Complete]/[Complete]/[Complete]
550 - permission denied
CWD /dir/[Complete]/[Complete]/[Complete]/[Complete]
550 - permission denied
CWD /dir/[Complete]/[Complete]/[Complete]/[Complete]/[Complete]
550 - permission denied

etc...

By transfer on local side this dir - all ОК

P.S. Excuse for bad English...
Comment 1 Nomadic 2007-05-03 17:17:27 UTC
oops...

>> By transfer on local side this dir - all ОК
on local transfer bug also present.....
Comment 2 Jernej Kos 2007-05-03 17:56:38 UTC
SVN commit 660745 by kostko:

Fixed infinite recursion in CWD command. Note that this can't go to trunk because trunk will be KDE4-only in just a moment.

BUG: 144989

 M  +9 -0      ftpsocket.cpp  


--- branches/kftpgrabber/0.8/src/engine/ftpsocket.cpp #660744:660745
@@ -1247,6 +1247,12 @@
           break;
         }
         case SentCwd: {
+          if (!socket()->getConfigInt("status.cwd")) {
+            // Change directory has failed and we should be silent (=error reporting is off)
+            socket()->resetCommandClass();
+            return;
+          }
+          
           // Check the directory listing cache
           DirectoryListing cached = Cache::self()->findCached(socket(), socket()->getCurrentDirectory());
           if (cached.isValid()) {
@@ -1560,6 +1566,7 @@
       switch (currentState) {
         case None: {
           targetDirectory = socket()->getConfig("params.cwd.path");
+          socket()->setConfig("status.cwd", 1);
           
           // If we are already there, no need to CWD
           if (socket()->getCurrentDirectory() == targetDirectory) {
@@ -1608,6 +1615,7 @@
               socket()->emitError(socket()->getPreviousCommand() == Commands::CmdList ? ListFailed : FileNotFound);
               socket()->resetCommandClass(Failed);
             } else {
+              socket()->setConfig("status.cwd", 0);
               socket()->resetCommandClass();
             }
           }
@@ -1629,6 +1637,7 @@
             socket()->emitError(socket()->getPreviousCommand() == Commands::CmdList ? ListFailed : FileNotFound);
             socket()->resetCommandClass(Failed);
           } else {
+            socket()->setConfig("status.cwd", 0);
             socket()->resetCommandClass();
           }
           break;