about summary refs log tree commit diff
path: root/inet
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-21 01:52:32 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-21 01:52:32 +0000
commit54e1cabce616d89ad657731531620b7cd88fb8e2 (patch)
treef4b2384540f7f7d7314d76b6ff08a98a76205117 /inet
parent6eb74f33650b4b55e8bc7679145e9293c4b43f2f (diff)
downloadglibc-54e1cabce616d89ad657731531620b7cd88fb8e2.tar.gz
glibc-54e1cabce616d89ad657731531620b7cd88fb8e2.tar.xz
glibc-54e1cabce616d89ad657731531620b7cd88fb8e2.zip
Update.
	* inet/rcmd.c (rresvport_af): Avoid using invliad values.  Wrap
	around in search if port IPPORT_RESERVED/2 has been test.

2002-02-20  Paolo Bonzini <bonzini@gnu.org>

	* posix/regcomp.c: Remove inclusions.
	* posix/regexec.c: Likewise.
	* posix/regex_internal.c: Likewise.
	* posix/regex_internal.h: Add inclusions here.
	* posix/regex.c: Only include sys/types.h before regex.h.  Include
	regex_internal.h here.  Include regex_internal.c before regcomp.c
	and regexec.c (might expose more opportunities to the C compiler).

	* posix/regcomp.c (parse_expression): Fix construct rejected by SGI CC.

	* posix/regex_internal.h [!_LIBC] (__mempcpy): Fix typo.
	[!_LIBC] (__wcrtomb): New definition.
	[!_LIBC]: Conditionalize enabling of I18N on HAVE_WCSCOLL and
	HAVE_LOCALE_H as well.

2003-02-20  Ulrich Drepper  <drepper@redhat.com>
Diffstat (limited to 'inet')
-rw-r--r--inet/rcmd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 4737e6e315..42871f7950 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -464,7 +464,14 @@ rresvport_af(alport, family)
 #endif
 	ss.ss_family = family;
 
-	for (;;) {
+	/* Ignore invalid values.  */
+	if (*alport < IPPORT_RESERVED / 2)
+		*alport = IPPORT_RESERVED / 2;
+	else if (*alport >= IPPORT_RESERVED)
+		*alport = IPPORT_RESERVED - 1;
+
+	int start = *alport;
+	do {
 		*sport = htons((uint16_t) *alport);
 		if (__bind(s, (struct sockaddr *)&ss, len) >= 0)
 			return s;
@@ -472,10 +479,9 @@ rresvport_af(alport, family)
 			(void)__close(s);
 			return -1;
 		}
-		(*alport)--;
-		if (*alport == IPPORT_RESERVED/2)
-			break;
-	}
+		if ((*alport)-- == IPPORT_RESERVED/2)
+			*alport = IPPORT_RESERVED - 1;
+	} while (*alport != start);
 	(void)__close(s);
 	__set_errno (EAGAIN);
 	return -1;