cURL / Mailing Lists / curl-library / Single Mail

curl-library

DNS round-robin multi-homed FTP server + EPSV = trouble

From: Richard Atterer <richard_at_list04.atterer.net>
Date: Sat, 4 Dec 2004 15:39:13 +0100

Hello,

I'm experiencing problems downloading data from ftp.de.kernel.org with my
libcurl application. This only happens with my own code, which calls
curl_multi_fdset() and select() itself. It does not happen with the
command-line curl.

The problem is that some of the servers behind that server name do not use a

  227 Entering passive mode. 127,0,0,1,4,51

style response, but instead a

  229 Entering Extended Passive Mode (|||53084|)

response. In the case of the 229 response, libcurl will *re-resolve* the
hostname before making the second connection, which is not a good idea,
because the returned IP address will be that of a different host, which
obviously won't be listening on that port... See the end of this mail for a
log.

In ftp.c:1569, newhostp is pointed to the string "ftp.de.kernel.org" for a
229, for a 227-style response it would point to newhost, which is filled
with an IPv4 address. In ftp.c:1601, the resolve takes place. (curl-7.12.2)

I was about to fix this and send a patch, but then started wondering: Is
there a good reason to re-resolve the hostname? The newhostp variable is
only there for 229-style responses, and the Curl_resolv() at ftp.c:1601 is
only given a hostname (and not an IP address) in the case of a 229
response.

RFC2428 says about the EPSV command:
  ...the network address used to establish the data connection will be the
  same network address used for the control connection.
so IMHO libcurl's behaviour is buggy.

Cheers,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/¯|  http://atterer.net  |  0x888354F7
  ¯ '` ¯
Trying to download
ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.9.tar.bz2:
* About to connect() to ftp.de.kernel.org port 21
*   Trying 129.143.116.10... 
           ^^^^^^^^^^^^^^
* Connected to ftp.de.kernel.org (129.143.116.10) port 21
< 220 beat me, break me! vsftpd, yeah baby!
> USER anonymous
< 331 Please specify the password.
> PASS curl_by_daniel_at_haxx.se
< 230-
[...]
< 230-This is the official anonymous FTP server of the Computing Center of the 
< 230-University of Applied Sciences, Esslingen. http://www.fht-esslingen.de/rz/
[...]
< 230-	  				   	      ... powered by Linux!
< 230 Login successful.
* We have successfully logged in
> PWD
< 257 "/"
* Entry path is '/'
> CWD pub
< 250-
[...]
< 250-	  				   	      ... powered by Linux!
< 250 Directory successfully changed.
> CWD linux
< 250 Directory successfully changed.
> CWD kernel
< 250 Directory successfully changed.
> CWD v2.6
< 250 Directory successfully changed.
> EPSV
< 229 Entering Extended Passive Mode (|||53084|)
*   Trying 131.159.72.23... * Connecting to ftp.de.kernel.org (131.159.72.23) port 53084
           ^^^^^^^^^^^^^
Received on 2004-12-04