mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
If only a partial file was transfered, we consider that a fatal problem so
we won't try to QUIT the control connection and risk "hanging" waiting for a response. Test case 161 verifies this. The quit-sending function was also made static.
This commit is contained in:
parent
33cb93ad0b
commit
1d3f76df71
47
lib/ftp.c
47
lib/ftp.c
@ -117,6 +117,7 @@ static CURLcode ftp_sendquote(struct connectdata *conn,
|
||||
static CURLcode ftp_cwd(struct connectdata *conn, char *path);
|
||||
static CURLcode ftp_mkd(struct connectdata *conn, char *path);
|
||||
static CURLcode ftp_cwd_and_mkd(struct connectdata *conn, char *path);
|
||||
static CURLcode ftp_quit(struct connectdata *conn);
|
||||
|
||||
/* easy-to-use macro: */
|
||||
#define FTPSENDF(x,y,z) if((result = Curl_ftpsendf(x,y,z))) return result
|
||||
@ -604,22 +605,22 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
||||
infof(data, "We have successfully logged in\n");
|
||||
if (conn->ssl[FIRSTSOCKET].use) {
|
||||
#ifdef HAVE_KRB4
|
||||
/* we are logged in (with Kerberos)
|
||||
* now set the requested protection level
|
||||
*/
|
||||
if(conn->sec_complete)
|
||||
Curl_sec_set_protection_level(conn);
|
||||
/* We are logged in with Kerberos, now set the requested protection
|
||||
* level
|
||||
*/
|
||||
if(conn->sec_complete)
|
||||
Curl_sec_set_protection_level(conn);
|
||||
|
||||
/* we may need to issue a KAUTH here to have access to the files
|
||||
* do it if user supplied a password
|
||||
*/
|
||||
if(conn->passwd && *conn->passwd) {
|
||||
result = Curl_krb_kauth(conn);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
/* We may need to issue a KAUTH here to have access to the files
|
||||
* do it if user supplied a password
|
||||
*/
|
||||
if(conn->passwd && *conn->passwd) {
|
||||
result = Curl_krb_kauth(conn);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
failf(data, "Odd return code after USER");
|
||||
@ -743,10 +744,13 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
||||
ssize_t nread;
|
||||
int ftpcode;
|
||||
CURLcode result=CURLE_OK;
|
||||
bool was_ctl_valid = ftp->ctl_valid;
|
||||
|
||||
/* free the dir tree and file parts */
|
||||
freedirs(ftp);
|
||||
|
||||
ftp->ctl_valid = FALSE;
|
||||
|
||||
if(data->set.upload) {
|
||||
if((-1 != data->set.infilesize) &&
|
||||
(data->set.infilesize != *ftp->bytecountp) &&
|
||||
@ -780,6 +784,8 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
||||
}
|
||||
}
|
||||
|
||||
ftp->ctl_valid = was_ctl_valid;
|
||||
|
||||
#ifdef HAVE_KRB4
|
||||
Curl_sec_fflush_fd(conn, conn->sock[SECONDARYSOCKET]);
|
||||
#endif
|
||||
@ -2312,7 +2318,7 @@ CURLcode ftp_perform(struct connectdata *conn,
|
||||
* The input argument is already checked for validity.
|
||||
*
|
||||
* ftp->ctl_valid starts out as FALSE, and gets set to TRUE if we reach the
|
||||
* end of the function.
|
||||
* Curl_ftp_done() function without finding any major problem.
|
||||
*/
|
||||
CURLcode Curl_ftp(struct connectdata *conn)
|
||||
{
|
||||
@ -2419,7 +2425,8 @@ CURLcode Curl_ftp(struct connectdata *conn)
|
||||
else
|
||||
freedirs(ftp);
|
||||
|
||||
ftp->ctl_valid = TRUE;
|
||||
ftp->ctl_valid = TRUE; /* seems good */
|
||||
|
||||
return retcode;
|
||||
}
|
||||
|
||||
@ -2474,7 +2481,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Curl_ftp_quit()
|
||||
* ftp_quit()
|
||||
*
|
||||
* This should be called before calling sclose() on an ftp control connection
|
||||
* (not data connections). We should then wait for the response from the
|
||||
@ -2482,7 +2489,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
|
||||
* connection.
|
||||
*
|
||||
*/
|
||||
CURLcode Curl_ftp_quit(struct connectdata *conn)
|
||||
static CURLcode ftp_quit(struct connectdata *conn)
|
||||
{
|
||||
ssize_t nread;
|
||||
int ftpcode;
|
||||
@ -2512,13 +2519,13 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
|
||||
bad in any way, sending quit and waiting around here will make the
|
||||
disconnect wait in vain and cause more problems than we need to.
|
||||
|
||||
Curl_ftp_quit() will check the state of ftp->ctl_valid. If it's ok it
|
||||
ftp_quit() will check the state of ftp->ctl_valid. If it's ok it
|
||||
will try to send the QUIT command, otherwise it will just return.
|
||||
*/
|
||||
|
||||
/* The FTP session may or may not have been allocated/setup at this point! */
|
||||
if(ftp) {
|
||||
(void)Curl_ftp_quit(conn); /* ignore errors on the QUIT */
|
||||
(void)ftp_quit(conn); /* ignore errors on the QUIT */
|
||||
|
||||
if(ftp->entrypath)
|
||||
free(ftp->entrypath);
|
||||
|
@ -22,7 +22,7 @@ test80 test81 test82 test83 test84 test85 test86 test87 test507 \
|
||||
test149 test88 test89 test90 test508 test91 test92 test203 test93 \
|
||||
test94 test95 test509 test510 test97 test98 test99 test150 test151 \
|
||||
test152 test153 test154 test155 test156 test157 test158 test159 test511 \
|
||||
test160
|
||||
test160 test161
|
||||
|
||||
# The following tests have been removed from the dist since they no longer
|
||||
# work. We need to fix the test suite's FTPS server first, then bring them
|
||||
|
39
tests/data/test161
Normal file
39
tests/data/test161
Normal file
@ -0,0 +1,39 @@
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
1oooooooooooooooooooooooooooooooooooooooooo2
|
||||
</data>
|
||||
<size>
|
||||
10928
|
||||
</size>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
ftp
|
||||
</server>
|
||||
<name>
|
||||
FTP RETR PASV
|
||||
</name>
|
||||
<command>
|
||||
ftp://%HOSTIP:%FTPPORT/161
|
||||
</command>
|
||||
</test>
|
||||
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
USER anonymous
|
||||
PASS curl_by_daniel@haxx.se
|
||||
PWD
|
||||
EPSV
|
||||
TYPE I
|
||||
SIZE 161
|
||||
RETR 161
|
||||
</protocol>
|
||||
<errorcode>
|
||||
18
|
||||
</errrorcode>
|
||||
</verify>
|
@ -258,6 +258,11 @@ while(<FILE>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
# GETNAME url.c:1901 getnameinfo()
|
||||
elsif($_ =~ /^GETNAME ([^ ]*):(\d*) (.*)/) {
|
||||
# not much to do
|
||||
}
|
||||
|
||||
# ADDR url.c:1282 getaddrinfo() = 0x5ddd
|
||||
elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) {
|
||||
# generic match for the filename+linenumber
|
||||
|
Loading…
Reference in New Issue
Block a user