[BusyBox] [PATCH] wget, missing htons

Stephane Billiart stephane at reefedge.com
Fri Dec 26 14:46:39 UTC 2003


wget in 1.00pre5 does not handle ports in URLs correctly as shown below

# wget http://192.168.0.1/index.html   
Connecting to 192.168.0.1[192.168.0.1]:80

# wget http://192.168.0.1:80/index.html 
Connecting to 192.168.0.1[192.168.0.1]:20480

# wget http://192.168.0.1:8000/h.html 
Connecting to 192.168.0.1[192.168.0.1]:16415

The attached patch fixes this problem.

-- 
Stephane
-------------- next part --------------
--- wget.c.orig	Fri Dec 26 09:41:40 2003
+++ wget.c	Fri Dec 26 09:37:43 2003
@@ -287,7 +287,7 @@
 	 * sites (i.e. ftp.us.debian.org) use round-robin DNS
 	 * and we want to connect to only one IP... */
 	bb_lookup_host(&s_in, server.host);
-	s_in.sin_port = server.port;
+	s_in.sin_port = htons(server.port);
 	if (quiet_flag==FALSE) {
 		fprintf(stdout, "Connecting to %s[%s]:%d\n",
 				server.host, inet_ntoa(s_in.sin_addr), ntohs(server.port));


More information about the busybox mailing list