Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Nov 1999 14:46:25 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Mike Spengler <mks@networkcs.com>
Cc:        Jeroen Ruigrok/Asmodai <asmodai@wxs.nl>, current@FreeBSD.ORG
Subject:   Re: named.conf oddity
Message-ID:  <Pine.BSF.4.10.9911031419420.2426-100000@alphplex.bde.org>
In-Reply-To: <199911030206.UAA39981@us.networkcs.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> It seems a recent update to lib/libc/net/inet_addr.c is the culprit here.
> Any IP address with a component of 34 will fail in inet_aton().  Here's a 
> patch that should fix it up:
> 
> 
> Index: inet_addr.c
> ===================================================================
> RCS file: /home/ncvs/src/lib/libc/net/inet_addr.c,v
> retrieving revision 1.9
> diff -u -r1.9 inet_addr.c
> --- inet_addr.c	1999/10/31 04:43:55	1.9
> +++ inet_addr.c	1999/11/03 02:01:52
> @@ -65,6 +65,8 @@
>  
>  #include <ctype.h>
>  #include <errno.h>
> +#include <limits.h>
> +#include <stdlib.h>
>  #include <string.h>
>  
>  /*
> @@ -98,7 +100,7 @@
>  	u_long val;
>  	char *c;
>  	char *endptr;
> -	int base, gotend, n;
> +	int gotend, n;
>  
>  	c = (char *)cp;
>  	n = 0;
> @@ -111,8 +113,10 @@
>  		errno = 0;
>  		val = strtoul(c, &endptr, 0);
>  
> -		if (val == ERANGE)	/* Fail completely if it overflowed. */
> +		if ((val == ULONG_MAX) && (errno == ERANGE)) {
> +			/* Fail completely if it overflowed. */
>  			return (0);
> +		}
>  		
>  		/* 
>  		 * If the whole string is invalid, endptr will equal
> 

The check should be simply `if (errno == ERANGE)'.  The (val == ULONG_MAX)
check is a harmless bug (harmless because non-overflowing values > 0xffffff,
including ULONG_MAX, cause a failure later).

Bruce



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9911031419420.2426-100000>