diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-08-18 23:17:33 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-08-18 23:17:33 +0000 |
commit | 74a6921bc454fcbf842a221e95ba5dc09b19049e (patch) | |
tree | aa04df572b3435faae0e9017ec68cd984ce02fbd /lib | |
parent | 490cccba3cfd5ba54ecb64a10fb63c2f0e94a67d (diff) |
Armel Asselin fixed a crash in the FTP code when using SINGLECWD mode and
files in the root directory.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ftp.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 */ |