about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-09-01 08:57:52 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-01-04 12:00:14 +0100
commite552550b409fda1369dc8f23c659c554632619e5 (patch)
treefa3b2d867f91b8b1443f5a908e20de4092990c3b
parent5515224932751ef13d382b7404fefc8e9c1057f5 (diff)
downloadglibc-e552550b409fda1369dc8f23c659c554632619e5.tar.gz
glibc-e552550b409fda1369dc8f23c659c554632619e5.tar.xz
glibc-e552550b409fda1369dc8f23c659c554632619e5.zip
getaddrinfo: In gaih_inet, use h_errno for certain status values only
h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be
accurate at this point.

(cherry picked from commit a2881ef01450295782b065f2f850f340d5c12c14)
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getaddrinfo.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d09261cac..410d132f28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 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
 	function lookup failures more reliable.
 
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 65394a37d6..668f7b7507 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -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;