cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: There is one bug for FTP over SOCKS4/5 proxy

From: Song Ma <songmash_at_gmail.com>
Date: Fri, 29 Jun 2007 17:34:22 +0800

2007/6/28, Daniel Stenberg <daniel_at_haxx.se>:
>
> Are you saying that the fix is something like this?
>
> --- lib/ftp.c 24 Jun 2007 19:32:33 -0000 1.416
> +++ lib/ftp.c 28 Jun 2007 10:58:47 -0000
> @@ -1662,7 +1662,9 @@
> 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);
> - if (conn->bits.tunnel_proxy)
> + if (conn->bits.tunnel_proxy ||
> + (data->set.proxytype == CURLPROXY_SOCKS4) ||
> + (data->set.proxytype == CURLPROXY_SOCKS5))
> /* 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);
>
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html

Hi Daniel,

Sorry for that yesterday I rushed to post the bug without providing patch
due to regression was not finished yet...

Yes the patch is like you posted for both PASV and EPSV mode:
--- ftp.c~ 2007-06-29 14:05:04.000000000 +0800
+++ ftp.c 2007-06-29 14:19:23.000000000 +0800
@@ -1611,7 +1611,9 @@
         if(ptr) {
           newport = (unsigned short)(num & 0xffff);

- if (conn->bits.tunnel_proxy)
+ if (conn->bits.tunnel_proxy
+ || data->set.proxytype == CURLPROXY_SOCKS5
+ || data->set.proxytype == CURLPROXY_SOCKS4)
             /* 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);
@@ -1663,7 +1665,8 @@
       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);
- if (conn->bits.tunnel_proxy || data->set.proxytype ==
CURLPROXY_SOCKS5
+ if (conn->bits.tunnel_proxy
+ || data->set.proxytype == CURLPROXY_SOCKS5
           || data->set.proxytype == CURLPROXY_SOCKS4)
         /* proxy tunnel -> use other host info because ip_addr_str is the
            proxy address not the ftp host */

The patch has been verified for FTP downloading via SOCKS4/5 proxy. Log file
is attached. The change also made 100% pass for regression.

Best Regards,
Song Ma

Received on 2007-06-29