Bug#482973: libc6: gethostbyname() fails on IPv4 addresses with hex components
Package: libc6
Version: 2.7-11
Severity: normal
gethostbyname() fails with an "unknown host" error for IP
addresses with hexadecimal components in them. decimal and octal
components are OK.
For instace, 0x7F.1 which is another way to represent 127.0.0.1
fails. 0177.1 is OK.
That breaks POSIX conformance. As per POSIX, gethostbyname()
should recognise the same IPv4 address notations as inet_addr().
The spec for inet_addr() gives:
a.b.c.d
When four parts are specified, each shall be interpreted as
a byte of data and assigned, from left to right, to the four
bytes of an Internet address.
a.b.c
When a three-part address is specified, the last part shall
be interpreted as a 16-bit quantity and placed in the
rightmost two bytes of the network address. This makes the
three-part address format convenient for specifying Class B
network addresses as "128.net.host".
a.b
When a two-part address is supplied, the last part shall be
interpreted as a 24-bit quantity and placed in the rightmost
three bytes of the network address. This makes the two-part
address format convenient for specifying Class A network
addresses as "net.host".
a
When only one part is given, the value shall be stored
directly in the network address without any byte
rearrangement.
All numbers supplied as parts in IPv4 dotted decimal notation
may be decimal, octal, or hexadecimal, as specified in the ISO C
standard (that is, a leading 0x or 0X implies hexadecimal;
otherwise, a leading '0' implies octal; otherwise, the number is
interpreted as decimal).
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.25-rc8 (PREEMPT)
Locale: LANG=en_GB.ISO-8859-15, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash
Versions of packages libc6 depends on:
ii libgcc1 1:4.3.0-4 GCC support library
libc6 recommends no packages.
-- debconf-show failed
Reply to: