summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2012-11-19 13:01:43 +0530
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2015-01-29 13:33:29 -0500
commit20ac5d44837b82c064dfabd3646ec1f4f6826263 (patch)
treeea18cbd1414484d3acec0544c9b29cd712c48819
parentdfc25d72984eb5a3354e104612d0ca0129af3f98 (diff)
downloadglibc-20ac5d44837b82c064dfabd3646ec1f4f6826263.tar.gz
Return EAI_SYSTEM if we're out of file descriptors
Resolves BZ #14719. Conflicts: ChangeLog NEWS
-rw-r--r--ChangeLog11
-rw-r--r--NEWS4
-rw-r--r--nss/getXXbyYY_r.c7
-rw-r--r--resolv/nss_dns/dns-host.c25
-rw-r--r--sysdeps/posix/getaddrinfo.c6
5 files changed, 46 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fc9ebcf8a..bef6c5c780 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-11-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+
+ [BZ #14719]
+ * nss/getXXbyYY_r.c (INTERNAL (REENTRANT_NAME)): Set h_errno to
+ NETDB_INTERNAL when NSS_STATUS_UNAVAIL.
+ * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname3_r): Set
+ h_errno to NETDB_INTERNAL when errno is EMFILE or ENFILE.
+ (_nss_dns_gethostbyname4_r): Likewise.
+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Set result to
+ EAI_SYSTEM if NSS_STATUS_UNAVAIL.
+
2013-09-25 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/powerpc64/stackguard-macros.h (POINTER_CHK_GUARD:
diff --git a/NEWS b/NEWS
index aa9544fa30..a9f0b50cf5 100644
--- a/NEWS
+++ b/NEWS
@@ -9,8 +9,8 @@ Version 2.16.1
* The following bugs are resolved with this release:
- 6530, 14195, 14547, 14459, 14476, 14562, 14621, 14648, 14699, 14756, 14831,
- 15078, 15754, 15755, 16072, 16431, 16617, 17048, 17137, 17187, 17325,
+ 6530, 14195, 14547, 14459, 14476, 14562, 14621, 14648, 14699, 14719, 14756,
+ 14831, 15078, 15754, 15755, 16072, 16431, 16617, 17048, 17137, 17187, 17325,
17625, 17630.
* CVE-2104-7817 The wordexp function could ignore the WRDE_NOCMD flag
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index d197c9be17..50c04068f2 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -276,7 +276,12 @@ done:
#endif
*result = status == NSS_STATUS_SUCCESS ? resbuf : NULL;
#ifdef NEED_H_ERRNO
- if (status != NSS_STATUS_SUCCESS && ! any_service)
+ if (status == NSS_STATUS_UNAVAIL)
+ /* Either we failed to lookup the functions or the functions themselves
+ had a system error. Set NETDB_INTERNAL here to let the caller know
+ that the errno may have the real reason for failure. */
+ *h_errnop = NETDB_INTERNAL;
+ else if (status != NSS_STATUS_SUCCESS && !any_service)
/* We were not able to use any service. */
*h_errnop = NO_RECOVERY;
#endif
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index a924d40844..00caff5a2e 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -203,6 +203,11 @@ _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result,
status = NSS_STATUS_TRYAGAIN;
h_errno = TRY_AGAIN;
break;
+ /* System has run out of file descriptors. */
+ case EMFILE:
+ case ENFILE:
+ h_errno = NETDB_INTERNAL;
+ /* Fall through. */
case ECONNREFUSED:
case ETIMEDOUT:
status = NSS_STATUS_UNAVAIL;
@@ -315,14 +320,26 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
&ans2p, &nans2p, &resplen2);
if (n < 0)
{
- if (errno == ESRCH)
+ switch (errno)
{
+ case ESRCH:
status = NSS_STATUS_TRYAGAIN;
h_errno = TRY_AGAIN;
+ break;
+ /* System has run out of file descriptors. */
+ case EMFILE:
+ case ENFILE:
+ h_errno = NETDB_INTERNAL;
+ /* Fall through. */
+ case ECONNREFUSED:
+ case ETIMEDOUT:
+ status = NSS_STATUS_UNAVAIL;
+ break;
+ default:
+ status = NSS_STATUS_NOTFOUND;
+ break;
}
- else
- status = (errno == ECONNREFUSED
- ? NSS_STATUS_UNAVAIL : NSS_STATUS_NOTFOUND);
+
*herrnop = h_errno;
if (h_errno == TRY_AGAIN)
*errnop = EAGAIN;
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 0146eb95b9..dd85130554 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1058,6 +1058,12 @@ gaih_inet (const char *name, const struct gaih_service *service,
_res.options |= old_res_options & RES_USE_INET6;
+ if (status == NSS_STATUS_UNAVAIL)
+ {
+ result = GAIH_OKIFUNSPEC | -EAI_SYSTEM;
+ goto free_and_return;
+ }
+
if (no_data != 0 && no_inet6_data != 0)
{
/* If both requests timed out report this. */