]> 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>
Thu, 4 Jan 2018 11:00:14 +0000 (12:00 +0100)
h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be
accurate at this point.

(cherry picked from commit a2881ef01450295782b065f2f850f340d5c12c14)

ChangeLog
sysdeps/posix/getaddrinfo.c

index 0d09261cac2f776288ae23b914664eb8b156c86e..410d132f284adfebadf0eddc1f000649b3768675 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 65394a37d6d28b6a475a500d0fa917b6c93b77e7..668f7b750796d869493afbdc3b6d03e8d97a5eb2 100644 (file)
@@ -944,7 +944,10 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
          _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;
 
-         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;