[Bug 792300] [NEW] getaddrinfo() AI_V4MAPPED flag doesn't work with hosts file
Nick Tait
792300 at bugs.launchpad.net
Fri Jun 3 10:48:16 UTC 2011
Public bug reported:
When using getaddrinfo() with family=AF_INET6 and flags=AI_V4MAPPED to
resolve a host name that is in /etc/hosts with an IPv4 address only, it
returns EAI_NODATA, instead of converting the IPv4 address to an
IPv4-mapped IPv6 address.
I have attached a program which demonstrates the bug. When you run this
program you specify the host name to resolve as a command-line argument.
The lines below show the relevant contents of my hosts file, and the
output of the program when used with "localhost", "127.0.0.1",
"localhost6", and "::1". It is only "localhost" which isn't working
properly. I would have expected this to return the same result as
"127.0.0.1" (in other words "::ffff:127.0.0.1") since my hosts file
defines localhost as being 127.0.0.1. (Please note this behaviour is not
specific to loopback addresses - I have used these in my example because
they should be able to used to reproduce this fault on any machine.)
nick at freddo:~/workspace/v4mappedtest$ grep localhost /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 freddo localhost6.localdomain6 localhost6
::1 ip6-localhost ip6-loopback
nick at freddo:~/workspace/v4mappedtest$ ./a.out localhost
No address associated with hostname
nick at freddo:~/workspace/v4mappedtest$ ./a.out 127.0.0.1
The following addresses were returned:
::ffff:127.0.0.1
nick at freddo:~/workspace/v4mappedtest$ ./a.out localhost6
The following addresses were returned:
::1
nick at freddo:~/workspace/v4mappedtest$ ./a.out ::1
The following addresses were returned:
::1
nick at freddo:~/workspace/v4mappedtest$
ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: libc6 2.13-0ubuntu13
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic i686
NonfreeKernelModules: nvidia
Architecture: i386
Date: Fri Jun 3 22:17:20 2011
ProcEnviron:
LANGUAGE=en_NZ:en
PATH=(custom, user)
LANG=en_NZ.UTF-8
SHELL=/bin/bash
SourcePackage: eglibc
UpgradeStatus: Upgraded to natty on 2011-04-29 (34 days ago)
** Affects: eglibc (Ubuntu)
Importance: Undecided
Status: New
** Tags: apport-bug i386 natty
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to eglibc in Ubuntu.
https://bugs.launchpad.net/bugs/792300
Title:
getaddrinfo() AI_V4MAPPED flag doesn't work with hosts file
Status in “eglibc” package in Ubuntu:
New
Bug description:
When using getaddrinfo() with family=AF_INET6 and flags=AI_V4MAPPED to
resolve a host name that is in /etc/hosts with an IPv4 address only,
it returns EAI_NODATA, instead of converting the IPv4 address to an
IPv4-mapped IPv6 address.
I have attached a program which demonstrates the bug. When you run
this program you specify the host name to resolve as a command-line
argument. The lines below show the relevant contents of my hosts file,
and the output of the program when used with "localhost", "127.0.0.1",
"localhost6", and "::1". It is only "localhost" which isn't working
properly. I would have expected this to return the same result as
"127.0.0.1" (in other words "::ffff:127.0.0.1") since my hosts file
defines localhost as being 127.0.0.1. (Please note this behaviour is
not specific to loopback addresses - I have used these in my example
because they should be able to used to reproduce this fault on any
machine.)
nick at freddo:~/workspace/v4mappedtest$ grep localhost /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 freddo localhost6.localdomain6 localhost6
::1 ip6-localhost ip6-loopback
nick at freddo:~/workspace/v4mappedtest$ ./a.out localhost
No address associated with hostname
nick at freddo:~/workspace/v4mappedtest$ ./a.out 127.0.0.1
The following addresses were returned:
::ffff:127.0.0.1
nick at freddo:~/workspace/v4mappedtest$ ./a.out localhost6
The following addresses were returned:
::1
nick at freddo:~/workspace/v4mappedtest$ ./a.out ::1
The following addresses were returned:
::1
nick at freddo:~/workspace/v4mappedtest$
ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: libc6 2.13-0ubuntu13
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic i686
NonfreeKernelModules: nvidia
Architecture: i386
Date: Fri Jun 3 22:17:20 2011
ProcEnviron:
LANGUAGE=en_NZ:en
PATH=(custom, user)
LANG=en_NZ.UTF-8
SHELL=/bin/bash
SourcePackage: eglibc
UpgradeStatus: Upgraded to natty on 2011-04-29 (34 days ago)
More information about the foundations-bugs
mailing list