[BusyBox] [PATCH] wget, missing htons

Stephane Billiart stephane at reefedge.com
Sat Dec 27 00:07:03 UTC 2003


On Fri, Dec 26, 2003 at 09:46:39AM -0500, Stephane Billiart wrote:
> 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

This new version also fixes the 'connecting' message, I use -q in my scripts
so I just realized the problem

-- 
Stephane
-------------- next part --------------
--- wget.c.orig	Fri Dec 26 09:41:40 2003
+++ wget.c	Fri Dec 26 19:02:29 2003
@@ -287,10 +287,10 @@
 	 * 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));
+				server.host, inet_ntoa(s_in.sin_addr), server.port);
 	}
 
 	if (proxy || !target.is_ftp) {


More information about the busybox mailing list