bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] wget doesn't handle 5-digit port numbers in EPSV reponses


From: Adam Sampson
Subject: [Bug-wget] wget doesn't handle 5-digit port numbers in EPSV reponses
Date: Sun, 4 Jan 2015 16:19:01 +0000
User-agent: Mutt/1.5.23+16 (39d3ddb56d34) (2014-03-12)

Dear wget authors,

When using wget --passive-ftp against IPv6 FTP servers, I occasionally
get the following error:

  ==> EPSV ....
  Cannot parse PASV response.

I finally found an FTP server that consistently had this problem today
(stunnel.mirt.net), and strace showed that the response in question was:

  229 Entering Extended Passive Mode (|||49854|).

This is a perfectly valid response. wget is getting confused because of
an off-by-one error in the code that parses the port number in ftp_epsv.
When the port number is 5 digits long, i will be 5 at the end of the
loop, so the test for an invalid port number length should check for it
being *greater than* 5.

Here's the trivial fix:

* ftp-basic.c (ftp_epsv): Accept 5-digit port numbers in EPSV responses.

diff -x config.log -x config.status -ru tmp/wget-1.16.1/src/ftp-basic.c 
work/wget-1.16.1/src/ftp-basic.c
--- tmp/wget-1.16.1/src/ftp-basic.c     2014-12-02 07:49:37.000000000 +0000
+++ work/wget-1.16.1/src/ftp-basic.c    2015-01-04 16:06:02.281000000 +0000
@@ -788,7 +788,7 @@
   for (tport = 0, i = 0; i < 5 && c_isdigit (*s); i++, s++)
       tport = (*s - '0') + 10 * tport;
 
-  if (i >= 5)
+  if (i > 5)
     {
       xfree (respline);
       return FTPINVPASV;

Thanks very much (and happy new year!),

-- 
Adam Sampson <address@hidden>                         <http://offog.org/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]