From 3d04f5db20c8f0d1ba3881b5f5373586a18cf188 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 21 May 2013 21:54:41 +0530 Subject: Set EAI_SYSTEM only when h_errno is NETDB_INTERNAL Fixes BZ #15339. 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 a simple 'not found', we set h_errno as NETDB_INTERNAL and let errno be the identifier for the exact error. --- sysdeps/posix/getaddrinfo.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sysdeps/posix/getaddrinfo.c') diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index ab135ada7f..7bb3ded9af 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -1036,7 +1036,15 @@ 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 failure was due to a system + error other than the file not being found. We use the + errno from the last failed callback. */ + if (errno != 0 && errno != ENOENT) + __set_h_errno (NETDB_INTERNAL); + } } if (nss_next_action (nip, status) == NSS_ACTION_RETURN) @@ -1050,7 +1058,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; -- cgit 1.4.1