Closed Bug 158830 Opened 22 years ago Closed 15 years ago

PR_StringToNetAddr("", *ptr) behaviour is inconsistent on windows & solaris

Categories

(NSPR :: NSPR, defect, P2)

x86
Windows 2000
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: gopinath.mr, Assigned: wtc)

References

Details

Attachments

(1 file)

Hi,
  When the hostname is given as empty string, the inet_address(..) method on
solaris returns -1 and on windows it returns 0 (NULL).  But the implementation
checks for only value -1 and returns PR_FAILURE.
 So on windows I get PR_SUCCESS and on solaris I get PR_FAILURE.
Additional check for return value is NULL has to be added for windows and should
return PR_FAILURE.
  NOTE: The value "0.0.0.0" returns zero on windows, so the only way to check
the error is 
#ifdef WINDOWS
  if (retValue == 0) {
    check whether string is empty or contains only space
    if yes,
          return PR_FAILURE
    else 
         // value was 0.0.0.0
   }
#endifI looked at NSPR implementation in file pr/src/misc/prnetdb.c
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
I found that inet_addr() behaves the same on Solaris and
Windows when the host name string begins with white space.
It returns 0 on both platforms.

The behavior is only different when the host name is an
empty string.  On Solaris inet_addr() returns -1 while on
Windows it returns 0.

I can test for an empty string on Windows and return
PR_FAILURE to make the behavior of PR_StringToNetAddr
consistent on Solaris and Windows, but it is strange
to return 0 on host names that begin with white space,
for example, " 10.169.2.10".
Priority: -- → P2
Target Milestone: --- → 4.3
Attached patch Proposed patchSplinter Review
This patch will make the PR_StringToNetAddr("", addr) behaviour
consistent on windows and solaris.
QA Contact: wtchang → nspr
The target milestone is already released. Resetting target milestone.
Target Milestone: 4.3 → ---
Fixed per bug 344809.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.8.4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: