]> granicus.if.org Git - curl/commitdiff
Armel Asselin fixed a crash in the FTP code when using SINGLECWD mode and
authorDaniel Stenberg <daniel@haxx.se>
Fri, 18 Aug 2006 23:17:33 +0000 (23:17 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 18 Aug 2006 23:17:33 +0000 (23:17 +0000)
files in the root directory.

CHANGES
RELEASE-NOTES
lib/ftp.c

diff --git a/CHANGES b/CHANGES
index bacba4bd8bcb68ce5fc9e093556966e73aec9032..74c321984f46b8d28dedab59491dad021c2e2b9a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,9 @@
                                   Changelog
 
 Daniel (19 August 2006)
+- Armel Asselin fixed a crash in the FTP code when using SINGLECWD mode and
+  files in the root directory.
+
 - Andrew Biggs pointed out a "Expect: 100-continue" flaw where libcurl didn't
   send the whole request at once, even though the Expect: header was disabled
   by the application. An effect of this change is also that small (< 1024
index 1f90ffe89e040c2067f6363bc325e56092236a81..49698e5245d6e5a3a8d73ed2014b1aab086c5ea4 100644 (file)
@@ -15,6 +15,8 @@ This release includes the following changes:
 
 This release includes the following bugfixes:
 
+ o SINGLECWD mode and using files in the root dir
+ o Expect: header disabling work better
  o "Expect: 100-continue" disable on second POST on re-used connection
  o src/config.h.in is fixed
 
index a52ad56a84c133f447b4e29a92009e66cbcff1d1..e7d8b2269a964fc8206a9616b846bb024868a87e 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3804,19 +3804,20 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
   case FTPFILE_SINGLECWD:
     /* get the last slash */
     slash_pos=strrchr(cur_pos, '/');
-    if(slash_pos) {
+    if(slash_pos || !cur_pos || !*cur_pos) {
       ftp->dirdepth = 1; /* we consider it to be a single dir */
       ftp->dirs = (char **)calloc(1, sizeof(ftp->dirs[0]));
       if(!ftp->dirs)
         return CURLE_OUT_OF_MEMORY;
 
-      ftp->dirs[0] = curl_easy_unescape(conn->data, cur_pos,
-                                        (int)(slash_pos-cur_pos), NULL);
+      ftp->dirs[0] = curl_easy_unescape(conn->data, slash_pos ? cur_pos : "/",
+                                        slash_pos?(int)(slash_pos-cur_pos):1,
+                                        NULL);
       if(!ftp->dirs[0]) {
         free(ftp->dirs);
         return CURLE_OUT_OF_MEMORY;
       }
-      ftp->file = slash_pos+1;  /* the rest is the file name */
+      ftp->file = slash_pos ? slash_pos+1 : cur_pos; /* rest is file name */
     }
     else
       ftp->file = cur_pos;  /* this is a file name only */