Bug 22196

Summary: if the first gethostbyname is for an ipv6 host it will fail
Product: Base System Reporter: Nick Johnson <freebsd>
Component: binAssignee: Hajimu UMEMOTO <ume>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1.1-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Nick Johnson 2000-10-21 20:50:01 UTC
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 */
Comment 1 dcs freebsd_committer freebsd_triage 2000-10-21 21:32:33 UTC
Responsible Changed
From-To: gnats-admin->freebsd-bugs

Moved from pending.
Comment 2 Johan Karlsson freebsd_committer freebsd_triage 2000-10-22 19:13:35 UTC
Responsible Changed
From-To: freebsd-bugs->ume

Let our IPv6 maintainer have a look at this.
Comment 3 Hajimu UMEMOTO freebsd_committer freebsd_triage 2000-10-27 13:35:41 UTC
State Changed
From-To: open->closed

Thanks!  I just committed it with slightly modified. (1.16 -> 1.17)