diff options
author | Yang Tse <yangsita@gmail.com> | 2011-09-12 15:16:07 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-09-12 15:16:07 +0200 |
commit | 4e9a1c5bba35e2eab7c2d9770a7cd4940372dbf8 (patch) | |
tree | b0095782833f1efd64a95ae67fc7cf23891f0e0d /lib | |
parent | 587ed3234bef1bf39491845c12d1391ff132be40 (diff) | |
download | curl-4e9a1c5bba35e2eab7c2d9770a7cd4940372dbf8.tar.gz |
ftp.c: fix socket leak torture tests detected 2011-08-30
Also fix inappropriate error handling when sending ftp EPRT or PORT commands.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ftp.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1000,8 +1000,14 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd], sa->sa_family == AF_INET?1:2, myhost, port); - if(result) + if(result) { + Curl_closesocket(conn, portsock); + /* don't retry using PORT */ + ftpc->count1 = PORT; + /* bail out */ + state(conn, FTP_STOP); return result; + } break; } else if(PORT == fcmd) { @@ -1021,8 +1027,12 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff)); result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp); - if(result) + if(result) { + Curl_closesocket(conn, portsock); + /* bail out */ + state(conn, FTP_STOP); return result; + } break; } } |