aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-12-05 23:33:33 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-12-05 23:33:33 +0000
commit35944744f84f8127529b315951946416fa592a7c (patch)
tree304600d51cee3959730e7fefb5be47ddac495e1b /lib/ftp.c
parent4b1c0bd1e7aefeee2a2116a9e56fbfb4eb11b2e4 (diff)
Richard Atterer fixed libcurl's way of dealing with the EPSV
response. Previously, libcurl would re-resolve the host name with the new port number and attempt to connect to that, while it should use the IP from the control channel. This bug made it hard to EPSV from an FTP server with multiple IP addresses!
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 47cb361aa..cc667acdb 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1519,8 +1519,8 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
/* newhost must be able to hold a full IP-style address in ASCII, which
in the IPv6 case means 5*8-1 = 39 letters */
- char newhost[48];
- char *newhostp=NULL;
+#define NEWHOST_BUFSIZE 48
+ char newhost[NEWHOST_BUFSIZE];
#ifdef PF_INET6
if(!conn->bits.ftp_use_epsv &&
@@ -1584,7 +1584,6 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
snprintf(newhost, sizeof(newhost),
"%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
- newhostp = newhost;
newport = (port[0]<<8) + port[1];
}
else if (229 == results[modeoff]) {
@@ -1613,8 +1612,8 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
if(ptr) {
newport = num;
- /* we should use the same host we already are connected to */
- newhostp = conn->host.name;
+ /* We must use the same IP we are already connected to */
+ Curl_printable_address(conn->ip_addr, newhost, NEWHOST_BUFSIZE);
}
}
else
@@ -1646,12 +1645,12 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
}
else {
/* normal, direct, ftp connection */
- rc = Curl_resolv(conn, newhostp, newport, &addr);
+ rc = Curl_resolv(conn, newhost, newport, &addr);
if(rc == CURLRESOLV_PENDING)
rc = Curl_wait_for_resolv(conn, &addr);
if(!addr) {
- failf(data, "Can't resolve new host %s:%d", newhostp, newport);
+ failf(data, "Can't resolve new host %s:%d", newhost, newport);
return CURLE_FTP_CANT_GET_HOST;
}
connectport = newport; /* we connect to the remote port */
@@ -1676,13 +1675,13 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
if(data->set.verbose)
/* this just dumps information about this second connection */
- ftp_pasv_verbose(conn, conninfo, newhostp, connectport);
+ ftp_pasv_verbose(conn, conninfo, newhost, connectport);
#ifndef CURL_DISABLE_HTTP
if(conn->bits.tunnel_proxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
result = Curl_ConnectHTTPProxyTunnel(conn, SECONDARYSOCKET,
- newhostp, newport);
+ newhost, newport);
if(CURLE_OK != result)
return result;
}