Closed Bug 70381 Opened 24 years ago Closed 24 years ago

PR_StringToNetAddr and PR_Bind on OSF1

Categories

(NSPR :: NSPR, defect, P3)

DEC
OSF/1
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(2 files)

This bug was reported by Chris Elving: I've run into a problem with PR_StringToNetAddr() and PR_Bind() on DEC. PR_StringToNetAddr() calls StringToV6Addr() which attempts to parse the string first as an IPv6 address and then as an IPv4 address. When the string is an IPv4 address, inet.pad in PRNetAddr is left with some junk in it. Unfortunately, bind() on DEC won't bind to an IPv4 address other than INADDR_ANY if the unused portion of sockaddr_in isn't zeroed out. I understand that BSD-derived TCP/IP stacks do a memcmp of the sockaddr you want to bind to with the sockaddr's of the network interfaces of the local host if you are binding to an IP address other than INADDR_ANY. This kind of problem has also been reported on AIX and NetBSD.
Attached patch Proposed patch.Splinter Review
Comments on my patch. 1. I took the opportunity to change PR_StringToNetAddr to parse the string first as an IPv4 address and then as an IPv6 address. Please let me know if this is a bad idea. 2. I added code to zero the 'inet.ip' field after we fail to parse the string as an IPv4 address. Does this patch look okay?
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → 4.1.1
Have you verified that inet_addr() will return -1 on ipv6 addresses?
No, I haven't. I'll attach a safer patch.
I checked in the safer patch (attachment id=26343) on the tip and NSPRPUB_RELEASE_4_1_BRANCH of NSPR.
Status: ASSIGNED → RESOLVED
Closed: 24 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: