]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Return EAI_SYSTEM if we're out of file descriptors
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Mon, 19 Nov 2012 07:31:43 +0000 (13:01 +0530)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 29 Jan 2015 18:33:29 +0000 (13:33 -0500)
Resolves BZ #14719.

Conflicts:
ChangeLog
NEWS

ChangeLog
NEWS
nss/getXXbyYY_r.c
resolv/nss_dns/dns-host.c
sysdeps/posix/getaddrinfo.c

index 6fc9ebcf8ab58f9d34ef5da0939c187239b73ccd..bef6c5c780c59e63b7b8aa3b633233e16ec41c89 100644 (file)
--- 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 aa9544fa30344e13da981cb6045199ae3a6f4f9d..a9f0b50cf55b62253dd31ec92c567f5759643b76 100644 (file)
--- 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
index d197c9be1759f4b8ca850e00ac6762520832e4c4..50c04068f230c85f544037d453118d0e0d178344 100644 (file)
@@ -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
index a924d40844a5737213bf11498b1c05ee27d32816..00caff5a2e81d9414edfe6ab703e8264d01ec89f 100644 (file)
@@ -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;
index 0146eb95b9830678c379411cba33bb9312133fb6..dd8513055456e2316e817ef9023e35b0ce6eff0b 100644 (file)
@@ -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.  */