]> granicus.if.org Git - curl/commitdiff
Richard Atterer fixed libcurl's way of dealing with the EPSV
authorDaniel Stenberg <daniel@haxx.se>
Sun, 5 Dec 2004 23:33:33 +0000 (23:33 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 5 Dec 2004 23:33:33 +0000 (23:33 +0000)
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!

CHANGES
RELEASE-NOTES
lib/ftp.c

diff --git a/CHANGES b/CHANGES
index d10d2b2bd603a5a845cd93b3d4fb6cc99a529df1..879f4d9fd17df4c9e78d152027f335cb66144cb2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,13 @@
 
                                   Changelog
 
+Daniel (6 December 2004)
+- 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!
+
 Daniel (3 December 2004)
 - Bug report #1078066: when a chunked transfer was pre-maturely closed exactly
   at a chunk boundary it was not considered an error and thus went unnoticed.
index 3d1626cd201276711d3c97c5f8b7755c2422f2d7..dd909bc44d9ca2d09ef0a29ddf660bfec6e46c4d 100644 (file)
@@ -23,6 +23,7 @@ This release includes the following changes:
 
 This release includes the following bugfixes:
 
+ o EPSV on multi-homed servers now works correctly
  o chunked-encoded transfers could get closed pre-maturely without error
  o proxy CONNECT now default timeouts after 3600 seconds
  o --disable-epsv and --disable-eprt are ignored when connecting to an IPv6 ftp
@@ -57,6 +58,7 @@ advice from friends like these:
  Peter Wullinger, Guillaume Arluison, Alexander Krasnostavsky, Mohun Biswas,
  Tomas Pospisek, Gisle Vanem, Dan Fandrich, Paul Nolan, Andres Garcia,
  Tim Sneddon, Ian Gulliver, Jean-Philippe Barrette-LaPierre, Jeff Phillips,
- Wojciech Zwiefka, David Phillips, Reinout van Schouwen, Maurice Barnum
+ Wojciech Zwiefka, David Phillips, Reinout van Schouwen, Maurice Barnum,
+ Richard Atterer
 
         Thanks! (and sorry if I forgot to mention someone)
index 47cb361aa113fcfb1297c9ddc97c606b8f435bea..cc667acdb9749e3f57c1a999e7b771b53be19f87 100644 (file)
--- 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;
   }