if (val > 0xffff)
if (parts[0] > 0xff || parts[1] > 0xff || val > 0xffff)
inet_aton(cp, addr)	const char *cp;	struct in_addr *addr;{	register u_int32_t val;	/* changed from u_long --david */#ifndef _LIBC	register int base;#endif	register int n;	register char c;	u_int32_t parts[4];	register u_int32_t *pp = parts;#ifdef _LIBC	int saved_errno = errno;	__set_errno (0);#endif	c = *cp;	for (;;) {		/*		 * Collect number up to ``.''.		 * Values are specified as for C:		 * 0x=hex, 0=octal, isdigit=decimal.		 */		if (!isdigit(c))			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;			if (c == 'x' || c == 'X')				base = 16, c = *++cp;			else				base = 8;		}		val = 0;		for (;;) {			if (isascii(c) && isdigit(c)) {				val = (val * base) + (c - '0');				c = *++cp;			} else if (base == 16 && isascii(c) && isxdigit(c)) {				val = (val << 4) |					(c + 10 - (islower(c) ? 'a' : 'A'));				c = *++cp;			} else				break;		}#endif		if (c == '.') {			/*			 * Internet format:			 *	a.b.c.d			 *	a.b.c	(with c treated as 16 bits)			 *	a.b	(with b treated as 24 bits)			 */			if (pp >= parts + 3)				goto ret_0;			*pp++ = val;			c = *++cp;		} else			break;	}	/*	 * Check for trailing characters.	 */	if (c != '\0' && (!isascii(c) || !isspace(c)))		goto ret_0;	/*	 * Concoct the address according to	 * the number of parts specified.	 */	n = pp - parts + 1;	switch (n) {	case 0:		goto ret_0;		/* initial nondigit */	case 1:				/* a -- 32 bits */		break;	case 2:				/* a.b -- 8.24 bits */		if (val > 0xffffff)			goto ret_0;		val |= parts[0] << 24;		break;	case 3:				/* a.b.c -- 8.8.16 bits */		if (val > 0xffff)			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)			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);}