--- curl-7.15.1\lib\ftp.c	Thu Jan 12 15:29:04 2006
+++ curl-7.15.1-patch\lib\ftp.c	Thu Jan 12 15:08:02 2006
@@ -1543,8 +1543,13 @@
         if(ptr) {
           newport = num;
 
-          /* use the same IP we are already connected to */
-          snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str);
+          if (conn->bits.tunnel_proxy)
+            /* proxy tunnel -> use other host info because ip_addr_str is the */
+            /* proxy address not the ftp host */
+            snprintf(newhost, sizeof(newhost), "%s", conn->host.name);
+          else
+            /* use the same IP we are already connected to */
+            snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str);
         }
       }
       else
@@ -1590,7 +1595,12 @@
       infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n",
             ip[0], ip[1], ip[2], ip[3],
             conn->ip_addr_str);
-      snprintf(newhost, sizeof(newhost), "%s", conn->ip_addr_str);
+      if (conn->bits.tunnel_proxy)
+        /* proxy tunnel -> use other host info because ip_addr_str is the */
+        /* proxy address not the ftp host */
+        snprintf(newhost, sizeof(newhost), "%s", conn->host.name);
+      else
+        snprintf(newhost, sizeof(newhost), "%s", conn->ip_addr_str);
     }
     else
       snprintf(newhost, sizeof(newhost),
