summary refs log tree commit diff
path: root/resolv/inet_addr.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-27 09:52:12 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-27 09:52:12 +0000
commit69bf5f75475e708abde760b2b401c2bfa65eec17 (patch)
tree2f0175634ce1e2b39c3437005de0bb7e61d3a06a /resolv/inet_addr.c
parentdb24ce47acb0727934bc8a0bedccf1be24791d13 (diff)
downloadglibc-69bf5f75475e708abde760b2b401c2bfa65eec17.tar.gz
glibc-69bf5f75475e708abde760b2b401c2bfa65eec17.tar.xz
glibc-69bf5f75475e708abde760b2b401c2bfa65eec17.zip
Update.
1998-06-27  7:07  Richard Henderson  <rth@cygnus.com>

	* math/atest-exp.c (exp_mpn, main): Cast to mp_limb_t appropriately.
	* math/atest-exp2.c (exp_mpn, main): Likewise.
	* math/atest-sincos.c (main): Likewise.

	* resolv/inet_addr.c (inet_aton): Check for 32-bit overflow.  Move
	base handling away from strtoul.  Always reset errno.

	* sysdeps/alpha/Makefile (elf): Kill -mno-fp-regs.

	* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Only set
	_dl_profile_map if _dl_name_match_p.
	(RTLD_START): Fix .prologue.  Set __libc_stack_end.
	* sysdeps/alpha/elf/start.S: Pass sp as arg 7.  Kill __data_start.

	* sysdeps/alpha/fpu/fraiseexcpt.c (feraiseexcept): Mark tmp
	as early-clobber.

	* sysdeps/libm-ieee754/e_exp10.c: Include "math_private.h".
	* sysdeps/libm-ieee754/e_exp10f.c: Likewise.
	* sysdeps/libm-ieee754/e_exp10l.c: Likewise.
Diffstat (limited to 'resolv/inet_addr.c')
-rw-r--r--resolv/inet_addr.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 635dd4596d..68659e9a04 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -102,13 +102,14 @@ inet_aton(cp, addr)
 	register u_int32_t val;	/* changed from u_long --david */
 	register int base, n;
 	register char c;
-	u_int parts[4];
-	register u_int *pp = parts;
+	u_int32_t parts[4];
+	register u_int32_t *pp = parts;
+
 #ifdef _LIBC
 	int saved_errno = errno;
-
 	__set_errno (0);
 #endif
+
 	c = *cp;
 	for (;;) {
 		/*
@@ -117,7 +118,18 @@ inet_aton(cp, addr)
 		 * 0x=hex, 0=octal, isdigit=decimal.
 		 */
 		if (!isdigit(c))
-			return (0);
+			goto ret_0;
+#ifdef _LIBC
+		{
+			unsigned long ul = strtoul (cp, (char **) &cp, 0);
+			if (ul == ULONG_MAX && errno == ERANGE)
+				goto ret_0;
+			if (ul > 0xfffffffful)
+				goto ret_0;
+			val = ul;
+		}
+		c = *cp;
+#else
 		base = 10;
 		if (c == '0') {
 			c = *++cp;
@@ -126,15 +138,6 @@ inet_aton(cp, addr)
 			else
 				base = 8;
 		}
-#ifdef _LIBC
-		val = strtoul (cp, (char **) &cp, base);
-		if (val == ULONG_MAX && errno == ERANGE)
-		{
-			__set_errno (saved_errno);
-			return 0;
-		}
-		c = *cp;
-#else
 		val = 0;
 		for (;;) {
 			if (isascii(c) && isdigit(c)) {
@@ -156,7 +159,7 @@ inet_aton(cp, addr)
 			 *	a.b	(with b treated as 24 bits)
 			 */
 			if (pp >= parts + 3)
-				return (0);
+				goto ret_0;
 			*pp++ = val;
 			c = *++cp;
 		} else
@@ -166,7 +169,7 @@ inet_aton(cp, addr)
 	 * Check for trailing characters.
 	 */
 	if (c != '\0' && (!isascii(c) || !isspace(c)))
-		return (0);
+		goto ret_0;
 	/*
 	 * Concoct the address according to
 	 * the number of parts specified.
@@ -175,30 +178,40 @@ inet_aton(cp, addr)
 	switch (n) {
 
 	case 0:
-		return (0);		/* initial nondigit */
+		goto ret_0;		/* initial nondigit */
 
 	case 1:				/* a -- 32 bits */
 		break;
 
 	case 2:				/* a.b -- 8.24 bits */
 		if (val > 0xffffff)
-			return (0);
+			goto ret_0;
 		val |= parts[0] << 24;
 		break;
 
 	case 3:				/* a.b.c -- 8.8.16 bits */
 		if (val > 0xffff)
-			return (0);
+			goto ret_0;
 		val |= (parts[0] << 24) | (parts[1] << 16);
 		break;
 
 	case 4:				/* a.b.c.d -- 8.8.8.8 bits */
 		if (val > 0xff)
-			return (0);
+			goto ret_0;
 		val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
 		break;
 	}
 	if (addr)
 		addr->s_addr = htonl(val);
+
+#ifdef _LIBC
+	__set_errno (saved_errno);
+#endif
 	return (1);
+
+ret_0:
+#ifdef _LIBC
+	__set_errno (saved_errno);
+#endif
+	return (0);
 }