| Summary: | if the first gethostbyname is for an ipv6 host it will fail | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Nick Johnson <freebsd> | ||||
| Component: | bin | Assignee: | Hajimu UMEMOTO <ume> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 4.1.1-RELEASE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Responsible Changed From-To: gnats-admin->freebsd-bugs Moved from pending. Responsible Changed From-To: freebsd-bugs->ume Let our IPv6 maintainer have a look at this. State Changed From-To: open->closed Thanks! I just committed it with slightly modified. (1.16 -> 1.17) |
gethostbyname checks to see if _res.options & RES_USE_INET6 is nonzero, but for the first call to gethostbyname, the resolver has not yet been initialized, so this test always fails the first time unless the right kind of junk is in _res. Fix: either explicitly call res_init() from the program before calling gethostbyname, or the following patch to /usr/src/lib/libc/net/gethostnamadr.c also works, although it's not pretty: How-To-Repeat: struct hostent *foo; setenv("RES_OPTIONS","inet6",1); foo = gethostbyname("spatula.none.freenet6.net"); printf("%p",foo); /* foo will be null */ foo = gethostbyname("spatula.none.freenet6.net"); printf("%p",foo); /* foo will have an address */