This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #15339] Make getaddrinfo set EAI_SYSTEM only when h_errno is NETDB_INTERNAL


Hi,

This regression was noted[1] by Dmitry Levin from a gnulib test run.

NSS_STATUS_UNAVAIL may mean that a necessary input resource is not
available.  This could occur in a number of cases including when the
network is down, system runs out of file descriptors, etc.  The
correct differentiator in such a case is the h_errno, which gives the
nature of failure.  In case of failures other than ENOENT, we set
h_errno as NETDB_INTERNAL and let errno be the identifier for the
exact error.

Verified that this fixes the reproducer Dmitry shared and also does
not regress the previous reproducer for ENFILE (BZ #14719).  The fix
also does not regress anything on `make xcheck`.  OK to commit?

Siddhesh

[1] http://sourceware.org/ml/libc-alpha/2013-03/msg00551.html

	[BZ #15339]
	* sysdeps/posix/getaddrinfo.c (gaih_inet): Set h_errno.
	Return EAI_SYSTEM if h_errno is NETDB_INTERNAL.

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 2309281..2928537 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1035,7 +1035,14 @@ gaih_inet (const char *name, const struct gaih_service *service,
 			}
 		    }
 		  else
-		    status = NSS_STATUS_UNAVAIL;
+		    {
+		      status = NSS_STATUS_UNAVAIL;
+		      /* Could not load any of the lookup functions.  Indicate
+		         an internal error if the file was found but some other
+		         error led to the failure.  */
+		      if (errno != ENOENT)
+			__set_h_errno (NETDB_INTERNAL);
+		    }
 		}
 
 	      if (nss_next_action (nip, status) == NSS_ACTION_RETURN)
@@ -1049,7 +1056,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
 	  _res.options |= old_res_options & RES_USE_INET6;
 
-	  if (status == NSS_STATUS_UNAVAIL)
+	  if (h_errno == NETDB_INTERNAL)
 	    {
 	      result = GAIH_OKIFUNSPEC | -EAI_SYSTEM;
 	      goto free_and_return;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]