mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
FTP: Make EPSV use the control IP address rather than the original host.
This ensures an alternate address is not used. Does not apply to proxy tunnel.
This commit is contained in:
parent
5bf472fd39
commit
3377e692ee
24
lib/ftp.c
24
lib/ftp.c
@ -1906,6 +1906,22 @@ static CURLcode proxy_magic(struct connectdata *conn,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *control_address(struct connectdata *conn)
|
||||||
|
{
|
||||||
|
/* Returns the control connection IP address.
|
||||||
|
If a proxy tunnel is used, returns the original host name instead, because
|
||||||
|
the effective control connection address is the proxy address,
|
||||||
|
not the ftp host. */
|
||||||
|
if(conn->bits.tunnel_proxy ||
|
||||||
|
conn->proxytype == CURLPROXY_SOCKS5 ||
|
||||||
|
conn->proxytype == CURLPROXY_SOCKS5_HOSTNAME ||
|
||||||
|
conn->proxytype == CURLPROXY_SOCKS4 ||
|
||||||
|
conn->proxytype == CURLPROXY_SOCKS4A)
|
||||||
|
return conn->host.name;
|
||||||
|
|
||||||
|
return conn->ip_addr_str;
|
||||||
|
}
|
||||||
|
|
||||||
static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
||||||
int ftpcode)
|
int ftpcode)
|
||||||
{
|
{
|
||||||
@ -1951,9 +1967,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
ftpc->newport = (unsigned short)(num & 0xffff);
|
ftpc->newport = (unsigned short)(num & 0xffff);
|
||||||
|
ftpc->newhost = strdup(control_address(conn));
|
||||||
/* use the original host name again */
|
|
||||||
ftpc->newhost = strdup(conn->host.name);
|
|
||||||
if(!ftpc->newhost)
|
if(!ftpc->newhost)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -2001,9 +2015,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
infof(data, "Skip %d.%d.%d.%d for data connection, re-use %s instead\n",
|
infof(data, "Skip %d.%d.%d.%d for data connection, re-use %s instead\n",
|
||||||
ip[0], ip[1], ip[2], ip[3],
|
ip[0], ip[1], ip[2], ip[3],
|
||||||
conn->host.name);
|
conn->host.name);
|
||||||
|
ftpc->newhost = strdup(control_address(conn));
|
||||||
/* use the original host name again */
|
|
||||||
ftpc->newhost = strdup(conn->host.name);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ftpc->newhost = aprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
ftpc->newhost = aprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
Loading…
Reference in New Issue
Block a user