]> granicus.if.org Git - curl/commitdiff
- I noticed while writing test 541 that the FTP code wrongly did a CWD on the
authorDaniel Stenberg <daniel@haxx.se>
Tue, 11 Sep 2007 22:21:39 +0000 (22:21 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 11 Sep 2007 22:21:39 +0000 (22:21 +0000)
  second transfer as it didn't store and remember the "" path from the
  previous transfer so it would instead CWD to the entry path as stored. This
  worked, but did a superfluous command. Thus, test case 541 now also verifies
  this fix.

lib/ftp.c

index a282282aa1b6929eb72fa422b86744b287bc7d55..cf5e590db5885b4736dd68427453e486652a0a7d 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2972,7 +2972,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn,
  *
  * Input argument is already checked for validity.
  */
-CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, bool premature)
+CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status,
+                       bool premature)
 {
   struct SessionHandle *data = conn->data;
   struct FTP *ftp = data->reqdata.proto.ftp;
@@ -3034,12 +3035,19 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, bool premature
   } else {
     size_t flen = ftp->file?strlen(ftp->file):0; /* file is "raw" already */
     size_t dlen = strlen(path)-flen;
-    if(dlen && !ftpc->cwdfail) {
-      ftpc->prevpath = path;
-      if(flen)
-        /* if 'path' is not the whole string */
-        ftpc->prevpath[dlen]=0; /* terminate */
-      infof(data, "Remembering we are in dir %s\n", ftpc->prevpath);
+    if(!ftpc->cwdfail) {
+      if(dlen) {
+        ftpc->prevpath = path;
+        if(flen)
+          /* if 'path' is not the whole string */
+          ftpc->prevpath[dlen]=0; /* terminate */
+      }
+      else {
+        /* we never changed dir */
+        ftpc->prevpath=strdup("");
+        free(path);
+      }
+      infof(data, "Remembering we are in dir \"%s\"\n", ftpc->prevpath);
     }
     else {
       ftpc->prevpath = NULL; /* no path */