1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

ftp: prevent server from hanging on closed data connection

Some FTP servers (e.g. Pure-ftpd) end up hanging if we close the data
connection before transferring all the requested data.  If we send ABOR
in that case, it prevents the server from hanging.

Bug: https://bugzilla.redhat.com/643656
Reported by: Pasi Karkkainen, Patrick Monnerat
This commit is contained in:
Kamil Dudka 2010-10-27 10:54:35 +02:00
parent 59db31902c
commit 0c8e5f7e6a
6 changed files with 11 additions and 1 deletions

View File

@ -3083,6 +3083,11 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
#endif #endif
if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) {
if(!result && ftpc->dont_check)
/* prevent some FTP servers (namely Pure-ftpd) from hanging if we close
* the data channel before transferring all data */
result = Curl_pp_sendf(&ftpc->pp, "ABOR");
if(conn->ssl[SECONDARYSOCKET].use) { if(conn->ssl[SECONDARYSOCKET].use) {
/* The secondary socket is using SSL so we must close down that part /* The secondary socket is using SSL so we must close down that part
first before we close the socket for real */ first before we close the socket for real */
@ -3097,7 +3102,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
} }
} }
if((ftp->transfer == FTPTRANSFER_BODY) && ftpc->ctl_valid && if(!result && (ftp->transfer == FTPTRANSFER_BODY) && ftpc->ctl_valid &&
pp->pending_resp && !premature) { pp->pending_resp && !premature) {
/* /*
* Let's see what the server says about the transfer we just performed, * Let's see what the server says about the transfer we just performed,

View File

@ -50,6 +50,7 @@ TYPE I
SIZE 1036 SIZE 1036
REST 20 REST 20
RETR 1036 RETR 1036
ABOR
QUIT QUIT
</protocol> </protocol>
<file name="log/curl1036.out"> <file name="log/curl1036.out">

View File

@ -45,6 +45,7 @@ TYPE I
SIZE 1057 SIZE 1057
REST 52 REST 52
RETR 1057 RETR 1057
ABOR
QUIT QUIT
</protocol> </protocol>
</verify> </verify>

View File

@ -46,6 +46,7 @@ TYPE I
SIZE 110 SIZE 110
REST 20 REST 20
RETR 110 RETR 110
ABOR
QUIT QUIT
</protocol> </protocol>
</verify> </verify>

View File

@ -39,6 +39,7 @@ EPSV
PASV PASV
TYPE I TYPE I
SIZE 122 SIZE 122
ABOR
QUIT QUIT
</protocol> </protocol>
</verify> </verify>

View File

@ -47,6 +47,7 @@ TYPE I
SIZE 135 SIZE 135
REST 4 REST 4
RETR 135 RETR 135
ABOR
QUIT QUIT
</protocol> </protocol>
</verify> </verify>