wget

Richard Kojedzinszky krichy at tvnetwork.hu
Fri Apr 21 15:15:13 UTC 2006


Dear all,

I made wget handle
PASV's results correctly, to read the ip address as well. This caused me 
trouble behind openbsd's pf and ftp-proxy.
The patch is attached.

Regards,
Kojedzinszky Richard
TvNetWork Rt.
E-mail: krichy at tvnetwork.hu
PGP: 0x24E79141
   Fingerprint = 6847 ECFF EF58 0C09 18A5  16CF 270F 0C6F 24E7 9141
-------------- next part --------------
--- busybox-1.01/networking/wget.c.orig	2005-12-29 11:19:40.000000000 +0100
+++ busybox-1.01/networking/wget.c	2005-12-29 11:42:57.000000000 +0100
@@ -165,10 +165,9 @@
 {
 	int n, try=5, status;
 	unsigned long opt;
-	int port;
 	char *proxy = 0;
 	char *dir_prefix=NULL;
-	char *s, buf[512];
+	char *s, *p, buf[512];
 	struct stat sbuf;
 	char extra_headers[1024];
 	char *extra_headers_ptr = extra_headers;
@@ -473,12 +472,16 @@
 		 */
 		if (ftpcmd("PASV", NULL, sfp, buf) !=  227)
 			close_delete_and_die("PASV: %s", buf+4);
-		s = strrchr(buf, ',');
-		*s = 0;
-		port = atoi(s+1);
-		s = strrchr(buf, ',');
-		port += atoi(s+1) * 256;
-		s_in.sin_port = htons(port);
+		s=p=strrchr(buf,'(') + 1;
+		for(n=0; n<4; n++) {
+			s=strchr(s, ',');
+			*s++ = '.';
+		}
+		s[-1] = 0;
+		inet_aton(p, &s_in.sin_addr);
+		s=strchr((p=s), ',');
+		*s++ = 0;
+		s_in.sin_port = htons(atoi(p)*256 + atoi(s));
 		dfp = open_socket(&s_in);
 
 		if (do_continue) {


More information about the busybox mailing list