Closed Bug 24763 Opened 25 years ago Closed 25 years ago

PR_GetIPNodeByName(host, PR_AF_INET6) doesn't include v4 addrs

Categories

(NSPR :: NSPR, defect, P3)

x86
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jgmyers, Assigned: srinivas)

Details

Attachments

(2 files)

On _PR_HAVE_GETHOSTBYNAME2 systems, PR_GetIPNodeByName(host, PR_AF_INET6)
will return either IPv4 or IPv6 addresses, but never both.
Attached patch proposed fixSplinter Review
To test, try:

gethost -6 www.6bone.net
Status: NEW → ASSIGNED
Checked in the patch, after fixing one error, along with additional 
modifications. Defined all the values for the 'flags' argument to 
PR_GetIPNodeByname; PR_AI_ALL, PR_AI_V4MAPPED and PR_AI_ADDRCONFIG. Both Ipv6 
and Ipv4-mapped addresses should be returned only when PR_AI_ALL is set.

Files modified:

/cvsroot/mozilla/nsprpub/pr/include/prnetdb.h
new revision: 3.4.4.2; previous revision: 3.4.4.1
/cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.
/cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.
According to my reading of RFC 2553, both IPv6 and IPv4-mapped addresses should 
be returned when PR_AI_DEFAULT is passed in and the host has both IPv4 and IPv6 
addresses configured.

In the gethostbyname2 case, we can likely get away with assuming the host has an 
IPv4 address configured; gethostbyname2 systems are unlikely to have resolvers 
that work over IPv6.  We are already returning IPv6 addresses in the 
gethostbyname2 AI_ADDRCONFIG case without first checking for a configured IPv6 
address, which is fine by me.
Ok, for systems with gethostbyname2, both ipv4 and ipv6 addresses should be 
returned when the flag is set to PR_AI_ALL or PR_AI_DEFAULT.
 
I will modify the check to read as

if ((flags & PR_AI_V4MAPPED) && (flags & (PR_AI_ALL|PR_AI_ADDRCONFIG))

before appending ipv4 addresses
File modified:

/cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c
new revision: 3.11.4.5; previous revision: 3.11.4.4 
I think you can resolve this as FIXED.
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: