Bug#52195: getaddrinfo() with PF_UNSPEC hints returns EAI_NODATA
Package: libc6
Version: 2.1.2-10
Security: Important
Even on IPv6 capable hosts, the getaddrinfo() function (defined in RFC2553)
with PF_UNSPEC hints returns EAI_NODATA error if the target host has only
AAAA record(s). In this case, it SHOULD return IPv6 addresses from AAAA
record(s) (on IPv6 capable hosts at least).
If PF_INET6 is given to getaddrinfo() as its "hints" argument, it will find
AAAA record(s). But this "ad hoc" solution is very imcompatible with other
IPv6 stack (such as FreeBSD + KAME) and breaks pure protocol independent
programming model.
Similar report is already done in debian-ipv6 ML
<http://www.debian.org/Lists-Archives/debian-ipv6-9911/msg00011.html>
but no records about this did not found in BTS.
This report is to record the problem to much more public space.
Note: After I copied /lib/libc-2.1.2.so from other Debian 2.1.2-5
box to my 2.1.2-10 box, it works fine.
(This is dangerous test.)
The test program:
/* gaitest.c */
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
struct AList{
int type;
char *name;
};
struct AList sock_alist[] = {
{ 0, "Unspecified" },
{ SOCK_STREAM, "SOCK_STREAM" },
{ SOCK_DGRAM, "SOCK_DGRAM" },
{ -1, NULL }
};
int main(int argc, char *argv[]){
char *name = "localhost";
char *service = NULL;
struct addrinfo hints, *ai;
int j;
int status;
if (argc>1) name = argv[1];
if (argc>2) service = argv[2];
ai=NULL;
printf ("getaddrinfo(\"%s\",\"%s\",&hints,&ai)\n",
name, service);
for(j=0; sock_alist[j].name; j++){
memset(&hints,sizeof(hints),0);
hints.ai_flags = 0;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = sock_alist[j].type;
status = getaddrinfo(name,service,&hints,&ai);
printf ("\tsocktype=%d(%s): %d = %s\n",
sock_alist[j].type,
sock_alist[j].name,
status,
(status ? gai_strerror(status) : "ok")
);
if(ai){ freeaddrinfo(ai);}
}
return (0);
}
----
The results on libc6-2.1.2-10 machine (buggy):
|% nslookup -q=any pandora.ipv6.debian.org
:
|Non-authoritative answer:
|pandora.ipv6.debian.org IPv6 address = 3ffe:600:8000:8::32
:
|% ./gaitest pandora.ipv6.debian.org
|getaddrinfo("pandora.ipv6.debian.org","(null)",&hints,&ai)
| socktype=0(Unspecified): -5 = No address associated with hostname
| socktype=1(SOCK_STREAM): -5 = No address associated with hostname
| socktype=2(SOCK_DGRAM): -5 = No address associated with hostname
|% ./gaitest pandora.ipv6.debian.org 80
|getaddrinfo("pandora.ipv6.debian.org","80",&hints,&ai)
| socktype=0(Unspecified): -8 = Servname not supported for ai_socktype
| socktype=1(SOCK_STREAM): -5 = No address associated with hostname
| socktype=2(SOCK_DGRAM): -5 = No address associated with hostname
On libc6-2.1.2-5 machine (seems ok):
|% ./gaitest pandora.ipv6.debian.org
|getaddrinfo("pandora.ipv6.debian.org","(null)",&hints,&ai)
| socktype=0(Unspecified): 0 = ok
| socktype=1(SOCK_STREAM): 0 = ok
| socktype=2(SOCK_DGRAM): 0 = ok
|./gaitest pandora.ipv6.debian.org 80
|getaddrinfo("pandora.ipv6.debian.org","80",&hints,&ai)
| socktype=0(Unspecified): -8 = Servname not supported for ai_socktype
| socktype=1(SOCK_STREAM): 0 = ok
| socktype=2(SOCK_DGRAM): 0 = ok
Thanks.
Desired=Unknown/Install/Remove/Purge
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-===============-==============-============================================
ii libc6 2.1.2-10 GNU C Library: Shared libraries and timezone
--
Hideaki YOSHIFUJI <yoshfuji@ecei.tohoku.ac.jp>
Web Page: http://www.ecei.tohoku.ac.jp/%7Eyoshfuji/
PGP5i FP: F731 6599 5EB2 BBA7 1515 1323 1806 A96F 5700 6B25
Reply to: