]> granicus.if.org Git - curl/commitdiff
FTP: skip CWD to entry dir when target is absolute
authorZenju <zenju@gmx.de>
Wed, 11 Sep 2019 18:04:28 +0000 (20:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 13 Sep 2019 12:05:34 +0000 (14:05 +0200)
Closes #4332

lib/ftp.c
tests/data/test1225

index e807a2acdeedf9692512eae798430d09a8a2b8ca..0793dc1f3a7b68b837c77f11ecafc1baeb7d5d68 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -877,7 +877,9 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
     if((conn->data->set.ftp_filemethod == FTPFILE_NOCWD) && !ftpc->cwdcount)
       /* No CWD necessary */
       result = ftp_state_mdtm(conn);
-    else if(conn->bits.reuse && ftpc->entrypath) {
+    else if(conn->bits.reuse && ftpc->entrypath &&
+            /* no need to go to entrypath when we have an absolute path */
+            !(ftpc->dirdepth && ftpc->dirs[0][0] == '/')) {
       /* This is a re-used connection. Since we change directory to where the
          transfer is taking place, we must first get back to the original dir
          where we ended up after login: */
index 2b2519c948ea219f8f72eef7144ad46a2a7e3da2..09a1abb79fbf41624bba87ce774820f73b376ada 100644 (file)
@@ -45,7 +45,6 @@ TYPE I
 SIZE 1225\r
 RETR 1225\r
 CWD /\r
-CWD /\r
 CWD foo\r
 CWD bar\r
 EPSV\r