If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

PR_GetHostByName() is not setting OS error correctly if gethostbyname_r() is used.

NEW
Assigned to

Status

NSPR
NSPR
P2
normal
17 years ago
11 years ago

People

(Reporter: Wan-Teh Chang, Assigned: Wan-Teh Chang)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Assignee)

Description

17 years ago
If gethostbyname_r() fails, the error code is stored in
the variable pointed to by the last argument.  PR_GetHostByName()
uses the value of h_errno as the error code if gethostbyname_r()
fails, which is incorrect.

Updated

17 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 1

17 years ago
On Red Hat Linux 7.1, if I pass a buffer size of 64 to
gethostbyname_r(), the function fails (returning NULL)
and sets the following error codes:
- h_err: -1 (NETDB_INTERNAL). (The address of h_err is
  the last argument to gethostbyname_r.)
- h_errno: unchanged.
- errno: 34 (ERANGE).

Looking at <netdb.h>, I believe the intention of setting
h_err to -1 is to instruct the caller to check errno for
the real error code even though the comments speak of
h_errno, which gethostbyname_r() doesn't use.

/* Possible values left in `h_errno'.  */
#define NETDB_INTERNAL  -1      /* See errno.  */

The error code ERANGE makes sense for this error because
the DNS lookup result is not representable with the given
scratch buffer size.

#define ERANGE          34      /* Math result not representable */
(Assignee)

Updated

17 years ago
Priority: -- → P2
Target Milestone: --- → 4.2

Comment 2

16 years ago
Reassign to wtc.
Assignee: larryh → wtc
Status: ASSIGNED → NEW
QA Contact: larryh → nspr
(Assignee)

Updated

11 years ago
Target Milestone: 4.2 → ---
You need to log in before you can comment on or make changes to this bug.