Summary: | glibc-2.6+ returns too many results from /etc/hosts in some cases | ||
---|---|---|---|
Product: | glibc | Reporter: | Mike Frysinger <vapier> |
Component: | libc | Assignee: | Ulrich Drepper <drepper.fsp> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | glibc-bugs, tonnerre, toolchain |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | unspecified | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Bug Depends on: | 4980 | ||
Bug Blocks: | |||
Attachments: | getaddrinfo.c test case |
Description
Mike Frysinger
2007-12-09 04:33:57 UTC
Created attachment 2128 [details]
getaddrinfo.c test case
running this test case on newer glibc's will show:
$ ./getaddrinfo localhost6
--- looking up 'localhost6' for family 0 (0)
getaddrinfo(...) = EAI_NONAME, trying again with AI_CANONNAME
getaddrinfo(...) = 0
getnameinfo(...) = 0
name = 127.0.0.1
service = 23
getnameinfo(...) = 0
name = ::1
service = 23
--- looking up 'localhost6' for family AF_INET (2)
getaddrinfo(...) = EAI_NONAME, trying again with AI_CANONNAME
getaddrinfo(...) = 0
getnameinfo(...) = 0
name = 127.0.0.1
service = 23
--- looking up 'localhost6' for family AF_INET6 (10)
getaddrinfo(...) = EAI_NONAME, trying again with AI_CANONNAME
getaddrinfo(...) = 0
getnameinfo(...) = 0
name = ::1
service = 23
on older glibc versions, that "127.0.0.1" entry wont crop up
Returning both entries is correct. It's the same in DNS: multiple entries are all returned. looking up "localhost6" should never result in "127.0.0.1" The code works as designed. This is no new change. Back in November 2006 I added code to map V6 addresses to v4 addresses in gethostbyname2(AF_INET) calls if it is possible. This is what happens here. The results are not wrong since you did not ask for a specific protocol. At some point, when we have unified lookup instead of separate IPv4/v6 lookups, this might change. But for now it works as expected and the program will work correctly. It is not obvious that the design of the current code makes any sense, but looks like we will never get to know the reasons behind it... c.f. http://sourceware.org/bugzilla/show_bug.cgi?id=4980 |