mirror of https://github.com/moparisthebest/curl
ftp.c: fix some leaks torture tests detected 2011-08-30 - follow-up
follow-up for commit d20408e8
This commit is contained in:
parent
437848d754
commit
fdf157abdf
22
lib/ftp.c
22
lib/ftp.c
|
@ -964,6 +964,13 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
||||||
conn->bits.ftp_use_eprt = TRUE;
|
conn->bits.ftp_use_eprt = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* we set the secondary socket variable to this for now, it is only so that
|
||||||
|
the cleanup function will close it in case we fail before the true
|
||||||
|
secondary stuff is made */
|
||||||
|
if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET])
|
||||||
|
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
|
||||||
|
conn->sock[SECONDARYSOCKET] = portsock;
|
||||||
|
|
||||||
for(; fcmd != DONE; fcmd++) {
|
for(; fcmd != DONE; fcmd++) {
|
||||||
|
|
||||||
if(!conn->bits.ftp_use_eprt && (EPRT == fcmd))
|
if(!conn->bits.ftp_use_eprt && (EPRT == fcmd))
|
||||||
|
@ -999,10 +1006,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
||||||
result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd],
|
result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd],
|
||||||
sa->sa_family == AF_INET?1:2,
|
sa->sa_family == AF_INET?1:2,
|
||||||
myhost, port);
|
myhost, port);
|
||||||
if(result) {
|
if(result)
|
||||||
Curl_closesocket(conn, portsock);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(PORT == fcmd) {
|
else if(PORT == fcmd) {
|
||||||
|
@ -1022,10 +1027,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
||||||
snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
|
snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
|
||||||
|
|
||||||
result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp);
|
result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp);
|
||||||
if(result) {
|
if(result)
|
||||||
Curl_closesocket(conn, portsock);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,13 +1036,6 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
||||||
/* store which command was sent */
|
/* store which command was sent */
|
||||||
ftpc->count1 = fcmd;
|
ftpc->count1 = fcmd;
|
||||||
|
|
||||||
/* we set the secondary socket variable to this for now, it is only so that
|
|
||||||
the cleanup function will close it in case we fail before the true
|
|
||||||
secondary stuff is made */
|
|
||||||
if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET])
|
|
||||||
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
|
|
||||||
conn->sock[SECONDARYSOCKET] = portsock;
|
|
||||||
|
|
||||||
/* this tcpconnect assignment below is a hackish work-around to make the
|
/* this tcpconnect assignment below is a hackish work-around to make the
|
||||||
multi interface with active FTP work - as it will not wait for a
|
multi interface with active FTP work - as it will not wait for a
|
||||||
(passive) connect in Curl_is_connected().
|
(passive) connect in Curl_is_connected().
|
||||||
|
|
Loading…
Reference in New Issue