[2.25 COMMITTED] getaddrinfo: In gaih_inet, use h_errno for certain status values only

Florian Weimer fweimer@redhat.com
Mon Jan 1 00:00:00 GMT 2018


h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be
accurate at this point.

(cherry picked from commit a2881ef01450295782b065f2f850f340d5c12c14)

2017-09-01  Florian Weimer  <fweimer@redhat.com>

	* sysdeps/posix/getaddrinfo.c (gaih_inet): Only use h_errno if
	status indicates it is set.

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;



More information about the Libc-stable mailing list