This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nss/21898] New: NSS functions set errno to 0
- From: "fweimer at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 03 Aug 2017 08:44:49 +0000
- Subject: [Bug nss/21898] New: NSS functions set errno to 0
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=21898
Bug ID: 21898
Summary: NSS functions set errno to 0
Product: glibc
Version: 2.26
Status: NEW
Severity: normal
Priority: P2
Component: nss
Assignee: unassigned at sourceware dot org
Reporter: fweimer at redhat dot com
Target Milestone: ---
Created attachment 10313
--> https://sourceware.org/bugzilla/attachment.cgi?id=10313&action=edit
test-nss-errno.c
The attached test case shows that gethostbyname, gethostbyname_r, and getpwnam
set errno to 0 upon success. POSIX does not allow this. getpwnam is in POSIX,
so this is a compliance issue.
errno after gethostbyname: 0
gethostbyname_r returns: 0
errno after gethostbyname_r: 0
errno after getpwnam: 0
This comes from the code in nss/getXXbyYY_r.c:
int res;
if (status == NSS_STATUS_SUCCESS || status == NSS_STATUS_NOTFOUND)
res = 0;
/* Don't pass back ERANGE if this is not for a too-small buffer. */
else if (errno == ERANGE && status != NSS_STATUS_TRYAGAIN)
res = EINVAL;
#ifdef NEED_H_ERRNO
/* These functions only set errno if h_errno is NETDB_INTERNAL. */
else if (status == NSS_STATUS_TRYAGAIN && *h_errnop != NETDB_INTERNAL)
res = EAGAIN;
#endif
else
return errno;
__set_errno (res);
return res;
We should probably check for res != 0 before calling __set_errno.
--
You are receiving this mail because:
You are on the CC list for the bug.