Closed Bug 394013 Opened 17 years ago Closed 17 years ago

vfyserv hostname lookup failure

Categories

(NSS :: Tools, defect, P2)

3.11
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: KaiE, Assigned: KaiE)

Details

Attachments

(1 file, 1 obsolete file)

I'm on Linux and I tried the vfyserv utility, both from 3.11.x and pre-3.12

This simple execution produces a failure:

$ vfyserv paypal.com
Error in function PR_GetHostByName: -5973
 - A directory lookup on a network address has failed.

Bob R was able to reproduce this failure.

Using "host paypal.com" works fine.

Running "vfyserv ip-address-of-paypal.com" is not really a good workaround, because it complains about hostname mismatch (of course).
May be an NSPR bug on Linux?  Maybe a Linux bug?

Kai, Since you run Linux and I don't, let me ask you to delve into this
with a debugger.  

Bug 366614 will change vfyserv to use an IPv6-capable replacement for
PR_GetHostByName soon.  So, if this is a bug in PR_GetHostByName, we
should identify that (and turn this into an NSPR bug) ASAP, before 
bug 366614 is fixed.
Version: trunk → 3.11
I had the same failure on my windows box.
Sigh. Maybe it should have taken me less time to find out, but after an hour of debugging, the answer is:

gethostbyname_r returns:
       ERANGE          34      /* Math result not representable */

vfyserv uses a 256 bytes buffer when calling PR_GetHostByName. This seems to be too small.

I will attach a patch to increase that buffer and make it work for me...

I have also filed bug 394375 where I propose that NSPR should set a better error code.
Attached patch Patch v1 (obsolete) — Splinter Review
Attachment #279023 - Flags: review?(nelson)
Assignee: nobody → kengert
OS: Linux → All
Hardware: PC → All
Comment on attachment 279023 [details] [diff] [review]
Patch v1

I'm baffled.  
This program has always worked for me!  Never any DNS lookup error.
I'm not THAT special. :)  So, why does it work for me and fail for you?

r=nelson.  I request one slight change:

>-	prStatus = PR_GetHostByName(hostName, buffer, 256, &hostEntry);
>+	prStatus = PR_GetHostByName(hostName, buffer, 1024, &hostEntry);

Please change that to:

>+	prStatus = PR_GetHostByName(hostName, buffer, sizeof buffer, &hostEntry);

So that we don't have to change this line again if we change the size of buffer.
Attachment #279023 - Flags: review?(nelson) → review+
Attached patch Patch v2Splinter Review
Actually there is an even better patch. There is a constant that can be used for the size of the buffer. Actually, there is another occurrence of that in the same source file which makes already use of that constant!!!

So here is a better patch, which uses the constant and the sizeof(buffer).
Attachment #279023 - Attachment is obsolete: true
Attachment #279025 - Flags: review?(nelson)
Comment on attachment 279025 [details] [diff] [review]
Patch v2

This is good.

>-	prStatus = PR_GetHostByName(hostName, buffer, 256, &hostEntry);
>+	prStatus = PR_GetHostByName(hostName, buffer, sizeof(buffer), &hostEntry);

Note that the parentheses around buffer are unnecessary. 
Parentheses are required only if the argument to sizeof is a type name, not
if it is an expression.  But it's OK this way.
Attachment #279025 - Flags: review?(nelson) → review+
Comment on attachment 279025 [details] [diff] [review]
Patch v2

I propose to land on 3.11 branch, too, requesting 2nd review.
Attachment #279025 - Flags: superreview?(rrelyea)
trunk:
/cvsroot/mozilla/security/nss/cmd/vfyserv/vfyserv.c,v  <--  vfyserv.c
new revision: 1.15; previous revision: 1.14
Comment on attachment 279025 [details] [diff] [review]
Patch v2

r+ rrelyea.

yes, much better then the original code.
Attachment #279025 - Flags: superreview?(rrelyea) → superreview+
3.11 branch:
/cvsroot/mozilla/security/nss/cmd/vfyserv/vfyserv.c,v  <--  vfyserv.c
new revision: 1.11.2.4; previous revision: 1.11.2.3

marking fixed
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
This wasn't failing on Solaris either, FYI.
Priority: -- → P2
Target Milestone: --- → 3.12
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: