Re: Possible /etc/hosts parsing bug?

Zach Brown (zab@grumblesmurf.net)
Sun, 17 Nov 1996 22:29:03 -0800 (PST)


On Sun, 17 Nov 1996, Mike wrote:

> In an effort to line everything up and make it look pretty I modified the
> previous lines to the following:
>
> 172.016.002.001 Atomic.shocking.com
> 172.016.002.002 Nuclear.shocking.com
> 172.016.002.003 Fusion.shocking.com
>
> Numerically, these have the same values, but when I tried to ping fusion,
> the IP that it was using was 172.14.2.3. When the extra '0's were deleted
> ping worked fine. Is this within the operating specs? Just curious,

inet_aton (the libc call that changes ascii representations of ip numbers
into actuall data) does the following:

if (*cp == '0') {
if (*++cp == 'x' || *cp == 'X')
base = 16, cp++;
else
base = 8;
}

so basically if you start one of the 'chunks' with a 0 (but no x/X) it
will try to decode it as octal (note that 016 = 1+8^1+6*8^0 = 14 decimal)

so to practice for v6 we should be doing 0xef.0.0.1 :)

oh, well, this is from my looking at the 5.4.7 tree.. i presume its been
like this for quite a while.

-- z