[PATCH] rcmd bug fix

Jakub Jelinek jakub@redhat.com
Mon May 29 08:30:00 GMT 2000


Hi!

This patch fixes rsh with glibc 2.1.90, otherwise I get
rcmd: socket: All ports in use
(obviously, because i is initialized with random garbage as seen by strace).

2000-05-29  Jakub Jelinek  <jakub@redhat.com>

	* inet/rcmd.c (rresvport_af): Use correct port number.

--- libc/inet/rcmd.c.jj	Mon May  8 14:30:39 2000
+++ libc/inet/rcmd.c	Mon May 29 16:59:49 2000
@@ -340,11 +340,9 @@ rresvport_af(alport, family)
 	ss.__ss_family = family;
 
 	for (;;) {
-		*sport = htons(i);
-		if (bind(s, (struct sockaddr *)&ss, len) >= 0){
-			*alport = i;
+		*sport = htons((uint16_t) *alport);
+		if (bind(s, (struct sockaddr *)&ss, len) >= 0)
 			return s;
-		}
 		if (errno != EADDRINUSE) {
 			(void)__close(s);
 			return -1;

	Jakub


More information about the Libc-hacker mailing list