[PATCH] setup.exe - problem with FTP

Marcel Telka marcel@telka.sk
Mon Jul 8 06:27:00 GMT 2002


Hi.

I've found little problem in the cygwin setup program:

There is no possibility to download files from some FTP servers (like
djb's publicfile ftpd http://cr.yp.to/publicfile/ftpd.html) because
the setup scans for '(' in a PASV FTP reply (code 227).

djb's ftpd uses this format for a PASV reply:

   227 =h1,h2,h3,h4,p1,p2


RFC 1123 (in section 4.1.2.6) says:

<cite>
The format of the 227 reply to a PASV command is not well standardized.
In particular, an FTP client cannot assume that the parentheses shown
on page 40 of RFC-959 will be present (and in fact, Figure 3 on page 43
omits them). Therefore, a User-FTP program that interprets the PASV reply
must scan the reply for the first digit of the host and port numbers. 
</cite>

I've considered this as a bug in the setup and created patch for nio-ftp.cc
file (see attachment). Please apply this patch to the CVS tree. Thanks.


ChangeLog entry:
================

2002-07-08  Marcel Telka  <marcel@telka.sk>

	* nio_ftp.cc (NetIO_FTP::NetIO_FTP): Fixed decoding of the FTP reply (code 227)
	to the PASV command.


Regards.

-- 
+-------------------------------------------+
| Marcel Telka   e-mail:   marcel@telka.sk  |
|                homepage: http://telka.sk/ |
|                jabber:   marcel@jabber.sk |
+-------------------------------------------+
-------------- next part --------------
diff -urNp setup-0.orig/nio-ftp.cc setup-0/nio-ftp.cc
--- setup-0.orig/nio-ftp.cc	2002-02-18 14:53:06.000000000 +0100
+++ setup-0/nio-ftp.cc	2002-06-12 19:56:01.000000000 +0200
@@ -125,13 +125,13 @@ NetIO_FTP::NetIO_FTP (char const *Purl, 
     return;
 
   char *
-    paren = strchr (last_line, '(');
-  if (!paren)
+    digit = strpbrk (last_line + 3, "0123456789");
+  if (!digit)
     return;
 
   int
     i1, i2, i3, i4, p1, p2;
-  sscanf (paren + 1, "%d,%d,%d,%d,%d,%d", &i1, &i2, &i3, &i4, &p1, &p2);
+  sscanf (digit, "%d,%d,%d,%d,%d,%d", &i1, &i2, &i3, &i4, &p1, &p2);
   char
     tmp[20];
   sprintf (tmp, "%d.%d.%d.%d", i1, i2, i3, i4);


More information about the Cygwin-apps mailing list