Bug 12885 - getaddrinfo with hints.ai_family=AF_INET6 succeeds even if resolving entry with no AAAA record
Summary: getaddrinfo with hints.ai_family=AF_INET6 succeeds even if resolving entry wi...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.14
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-14 06:41 UTC by Arkadiusz Miskiewicz
Modified: 2014-06-27 13:11 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
test case (419 bytes, application/octet-stream)
2011-06-14 06:41 UTC, Arkadiusz Miskiewicz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arkadiusz Miskiewicz 2011-06-14 06:41:12 UTC
Created attachment 5792 [details]
test case

glibc 2.14 getaddrinfo succeeds resolving dns entry that has A only record (and no AAAA) even if hits.ai_family was set to AF_INET6.

glibc 2.14 (invalid behaviour):

$ ./a.out
succeeded - BAD!
Got 209.132.183.81 port 0 family 2
Got 209.132.183.81 port 0 family 2
Got 209.132.183.81 port 0 family 2

glibc 2.13 (correct behaviour):
$ ./a.out
failed - OK!: Name or service not known

Test programs resolves redhat.com which at this moment has no AAAA record.
Comment 1 Andreas Schwab 2011-06-15 15:51:34 UTC
This is broken by bug 12714.
Comment 2 Ulrich Drepper 2011-06-21 21:05:58 UTC
I think the patch I applied fixes the problem.
Comment 3 Octoploid 2011-06-22 14:00:58 UTC
> I think the patch I applied fixes the problem.

It may fix the IPv6 problem, but unfortunately it breaks the IPv4 case.

% git pull
fatal: Unable to look up sourceware.org (port 9418) (No address associated with hostname)
([Errno -5] No address associated with hostname))
Comment 4 Octoploid 2011-06-23 10:16:10 UTC
Fixed by Andreas' commit.