]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
getaddrinfo: In gaih_inet, use h_errno for certain status values only
authorFlorian Weimer <fweimer@redhat.com>
Fri, 1 Sep 2017 06:57:52 +0000 (08:57 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 1 Sep 2017 06:57:52 +0000 (08:57 +0200)
h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be
accurate at this point.

ChangeLog
sysdeps/posix/getaddrinfo.c

index 4229a83b9c87413f089033630806c0c284a2ea51..f86a4354482bbacb15f73328bff64df50fe34b64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-01  Florian Weimer  <fweimer@redhat.com>
+
+       * sysdeps/posix/getaddrinfo.c (gaih_inet): Only use h_errno if
+       status indicates it is set.
+
 2017-09-01  Florian Weimer  <fweimer@redhat.com>
 
        * sysdeps/posix/getaddrinfo.c (gaih_inet): Make reporting of NSS
index 95b514873d79d1ab73f4d2e74a91d9d5fba4fff5..acb5d9e73d0e21f433948cbe041e44db4c6ce4fe 100644 (file)
@@ -948,7 +948,10 @@ gaih_inet (const char *name, const struct gaih_service *service,
          __resolv_context_enable_inet6 (res_ctx, res_enable_inet6);
          __resolv_context_put (res_ctx);
 
-         if (h_errno == NETDB_INTERNAL)
+         /* If we have a failure which sets errno, report it using
+            EAI_SYSTEM.  */
+         if ((status == NSS_STATUS_TRYAGAIN || status == NSS_STATUS_UNAVAIL)
+             && h_errno == NETDB_INTERNAL)
            {
              result = -EAI_SYSTEM;
              goto free_and_return;