aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-07-20 00:18:11 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-07-20 00:18:11 +0000
commit5e133e2dff3f466c194d89672219bcfbee205072 (patch)
treec6e900aec06635a21148708f75714201c31edb05
parent0049c09fc3890768bedf0a280889487d9828f9a0 (diff)
David Gardner pointed out in bug report 770755 that using the FTP command CWD
with a blank argument is a bad idea. Now skip blanks.
-rw-r--r--lib/ftp.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 118216c09..2f395eff0 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2135,17 +2135,24 @@ CURLcode Curl_ftp(struct connectdata *conn)
/* parse the URL path into separate path components */
while((slash_pos=strchr(cur_pos, '/'))) {
/* seek out the next path component */
- if (0 == slash_pos-cur_pos) /* empty path component, like "x//y" */
- ftp->dirs[path_part] = strdup(""); /* empty string */
- else
+ if (slash_pos-cur_pos) {
+ /* we skip empty path components, like "x//y" since the FTP command CWD
+ requires a parameter and a non-existant parameter a) doesn't work on
+ many servers and b) has no effect on the others. */
ftp->dirs[path_part] = curl_unescape(cur_pos,slash_pos-cur_pos);
- if (!ftp->dirs[path_part]) { /* run out of memory ... */
- failf(data, "no memory");
- retcode = CURLE_OUT_OF_MEMORY;
+ if (!ftp->dirs[path_part]) { /* run out of memory ... */
+ failf(data, "no memory");
+ retcode = CURLE_OUT_OF_MEMORY;
+ }
}
else {
cur_pos = slash_pos + 1; /* jump to the rest of the string */
+ continue;
+ }
+
+ if(!retcode) {
+ cur_pos = slash_pos + 1; /* jump to the rest of the string */
if(++path_part >= (CURL_MAX_FTP_DIRDEPTH-1)) {
/* too deep, we need the last entry to be kept NULL at all
times to signal end of list */