aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-05-23 11:14:09 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-05-23 11:14:09 +0000
commite2f4656a8696480514f5096ff9ea64aa3129934a (patch)
tree153dc078022a265488986ba7904b487c9927c0a6
parent1e14da5c606a2acd5e17afe3cbf4a402a6178433 (diff)
Ricardo Cadime found a socket leak when listing directories without
contents. Test cases 144 and 145 were added to verify the fix. Now we deal with return code 450 properly and other codes also do proper cleanup.
-rw-r--r--lib/ftp.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 885ad243c..6fa2982a0 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1184,7 +1184,6 @@ CURLcode ftp_use_port(struct connectdata *conn)
return result;
if (ftpcode != 200) {
- failf(data, "Server does not grok %s", *modep);
continue;
}
else
@@ -1193,6 +1192,7 @@ CURLcode ftp_use_port(struct connectdata *conn)
if (!*modep) {
sclose(portsock);
+ failf(data, "PORT command attempts failed");
return CURLE_FTP_PORT_FAILED;
}
/* we set the secondary socket variable to this for now, it
@@ -1931,8 +1931,14 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
return result;
}
else {
- failf(data, "%s", buf+4);
- return CURLE_FTP_COULDNT_RETR_FILE;
+ if(dirlist && (ftpcode == 450)) {
+ /* simply no matching files */
+ ftp->no_transfer = TRUE; /* don't think we should download anything */
+ }
+ else {
+ failf(data, "%s", buf+4);
+ return CURLE_FTP_COULDNT_RETR_FILE;
+ }
}
}
@@ -2180,16 +2186,19 @@ CURLcode Curl_ftp(struct connectdata *conn)
if(CURLE_OK == retcode) {
if(connected)
retcode = Curl_ftp_nextconnect(conn);
- else {
- if(ftp->no_transfer) {
- /* no data to transfer */
- retcode=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
- }
- else {
- /* since we didn't connect now, we want do_more to get called */
- conn->bits.do_more = TRUE;
- }
+
+ if(retcode && (conn->secondarysocket >= 0)) {
+ /* Failure detected, close the second socket if it was created already */
+ sclose(conn->secondarysocket);
+ conn->secondarysocket = -1;
}
+
+ if(ftp->no_transfer)
+ /* no data to transfer */
+ retcode=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ else if(!connected)
+ /* since we didn't connect now, we want do_more to get called */
+ conn->bits.do_more = TRUE;
}
return retcode;