develooper Front page | perl.perl5.porters | Postings from March 2011

Re: [perl #85308] perlbug AutoReply: inet_aton in Socket.pm coremodule is broken

From:
Quanah Gibson-Mount
Date:
March 4, 2011 21:14
Subject:
Re: [perl #85308] perlbug AutoReply: inet_aton in Socket.pm coremodule is broken
Message ID:
D1863E510256DDEDC73E1503@[192.168.1.2]
--On Wednesday, March 02, 2011 3:35 PM -0800 perlbug-followup@perl.org 
wrote:

> Greetings,
>
> This message has been automatically generated in response to the
> creation of a perl bug report regarding:
>    "inet_aton in Socket.pm core module is broken".

Here is an example.

If /etc/hosts is ordered with IPv6 before IPv4, inet_aton fails to return 
any data:

zimbra@zqa-064:~/libexec$ ./qtest.pl
ldap: Net::LDAP=HASH(0x248bbb8)
host: zqa-064.eng.vmware.com:389
arg: HASH(0x21898d0)
Host adjusted to: zqa-064.eng.vmware.com
Port adjusted to: 389
Creating socket
IO::Socket::INET Address:
IO::Socket::INET Address: zqa-064.eng.vmware.com
IO::Socket::Inet addr_str: zqa-064.eng.vmware.com
IO::Socket::INET h:
IO::Socket::INET: connect: Connection refused at ./qtest.pl line 44, <DATA> 
line 522.

"IO::Socket::INET h:" is the value of inet_aton.

Example /etc/hosts used here:

127.0.0.1   localhost

# The following lines are desirable for IPv6 capable hosts
#::1    zqa-064.eng.vmware.com  zqa-064 localhost   ip6-localhost 
ip6-loopback
::1 localhost   ip6-localhost   ip6-loopback    zqa-064.eng.vmware.com 
zqa-064
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes    zqa-064.eng.vmware.com  zqa-064
ff02::2 ip6-allrouters

10.137.245.250 w1-zbuild-ns120-01-qa-nfs.eng.vmware.com 
w1-zbuild-ns120-01-qa-nfs
10.137.244.64   zqa-064.eng.vmware.com  zqa-064

Even modifying it thusly doesn't change the behavior:

# The following lines are desirable for IPv6 capable hosts
#::1    zqa-064.eng.vmware.com  zqa-064 localhost       ip6-localhost 
ip6-loopback
::1     localhost       ip6-localhost   ip6-loopback 
zqa-064.eng.vmware.com  zqa-064
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes    zqa-064.eng.vmware.com  zqa-064
ff02::2 ip6-allrouters

127.0.0.1       localhost

10.137.245.250 w1-zbuild-ns120-01-qa-nfs.eng.vmware.com 
w1-zbuild-ns120-01-qa-nfs
10.137.244.64   zqa-064.eng.vmware.com  zqa-064



Now, if I move the IPv4 addresses to be before the IPv6 configuration, 
things work:

zimbra@zqa-064:~/libexec$ ./qtest.pl
ldap: Net::LDAP=HASH(0x1f13bb8)
host: zqa-064.eng.vmware.com:389
arg: HASH(0x1c118d0)
Host adjusted to: zqa-064.eng.vmware.com
Port adjusted to: 389
Creating socket
IO::Socket::INET Address:
IO::Socket::INET Address: zqa-064.eng.vmware.com
IO::Socket::Inet addr_str: zqa-064.eng.vmware.com
IO::Socket::INET h:
??@
Leaving function

Here is /etc/hosts for this run:

127.0.0.1       localhost

10.137.245.250 w1-zbuild-ns120-01-qa-nfs.eng.vmware.com 
w1-zbuild-ns120-01-qa-nfs
10.137.244.64   zqa-064.eng.vmware.com  zqa-064

# The following lines are desirable for IPv6 capable hosts
#::1    zqa-064.eng.vmware.com  zqa-064 localhost       ip6-localhost 
ip6-loopback
::1     localhost       ip6-localhost   ip6-loopback 
zqa-064.eng.vmware.com  zqa-064
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes    zqa-064.eng.vmware.com  zqa-064
ff02::2 ip6-allrouters


It basically seems that Perl's inet_aton stops parsing /etc/hosts for IPv4 
addresses as soon as it encounters its first IPv6 address definition, which 
would be  bug.

--Quanah

--

Quanah Gibson-Mount
Sr. Member of Technical Staff
Zimbra, Inc
A Division of VMware, Inc.
--------------------
Zimbra ::  the leader in open source messaging and collaboration



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About