[BusyBox] Patch for libbb/xconnect.c
Stewart Brodie
stewart.brodie at pace.co.uk
Fri Jul 19 11:07:03 UTC 2002
In message <Pine.LNX.4.30.0207191246260.26272-100000 at cac0.wmi.com>
Joel Coltoff <joel at wmi.com> wrote:
> On both my host system and with mipsel-linux for my embedded systems
> the function getservbyname() gives the port number already in host order.
The port number in the s_port field of a struct servent which was filled in
by getservbyname should be in *network* byte order. I think that's what you
meant, but your patch is right anyway (although it looks back-to-front - does
patch catch that properly?)
> --- libbb/xconnect.c.new Fri Jul 19 12:43:23 2002
> +++ libbb/xconnect.c Fri Jul 19 12:43:08 2002
> @@ -57,7 +57,7 @@
> struct sockaddr_in s_addr;
> int s = socket(AF_INET, SOCK_STREAM, 0);
> struct servent *tserv;
> - int port_nr=htons(atoi(port));
> + int port_nr=atoi(port);
> struct hostent * he;
>
> if (port_nr==0 && (tserv = getservbyname(port, "tcp")) != NULL)
> @@ -65,7 +65,7 @@
>
> memset(&s_addr, 0, sizeof(struct sockaddr_in));
> s_addr.sin_family = AF_INET;
> - s_addr.sin_port = port_nr;
> + s_addr.sin_port = htons(port_nr);
>
> he = xgethostbyname(host);
> memcpy(&s_addr.sin_addr, he->h_addr, sizeof s_addr.sin_addr);
>
--
Stewart Brodie, Senior Software Engineer
Pace Micro Technology PLC
645 Newmarket Road
Cambridge, CB5 8PB, United Kingdom WWW: http://www.pacemicro.com/
More information about the busybox
mailing list