From ea4924ce5bccfccc4e8a492faa96933131abd9ef Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 19 Jun 2017 14:05:49 +0200 Subject: resolv: Report allocation errors in __res_vinit --- resolv/nss_dns/dns-host.c | 18 +++++++++++++++--- resolv/nss_dns/dns-network.c | 12 ++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'resolv/nss_dns') diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index f121aa3..206924d 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -164,7 +164,11 @@ _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result, enum nss_status status; if (__res_maybe_init (&_res, 0) == -1) - return NSS_STATUS_UNAVAIL; + { + *errnop = errno; + *h_errnop = NETDB_INTERNAL; + return NSS_STATUS_UNAVAIL; + } switch (af) { case AF_INET: @@ -289,7 +293,11 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, int *herrnop, int32_t *ttlp) { if (__res_maybe_init (&_res, 0) == -1) - return NSS_STATUS_UNAVAIL; + { + *errnop = errno; + *herrnop = NETDB_INTERNAL; + return NSS_STATUS_UNAVAIL; + } /* * if there aren't any dots, it could be a user-level alias. @@ -416,7 +424,11 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, host_data = (struct host_data *) buffer; if (__res_maybe_init (&_res, 0) == -1) - return NSS_STATUS_UNAVAIL; + { + *errnop = errno; + *h_errnop = NETDB_INTERNAL; + return NSS_STATUS_UNAVAIL; + } if (af == AF_INET6 && len == IN6ADDRSZ && (memcmp (uaddr, mapped, sizeof mapped) == 0 diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c index 2be72d3..dc1599b 100644 --- a/resolv/nss_dns/dns-network.c +++ b/resolv/nss_dns/dns-network.c @@ -116,7 +116,11 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result, enum nss_status status; if (__res_maybe_init (&_res, 0) == -1) - return NSS_STATUS_UNAVAIL; + { + *errnop = errno; + *herrnop = NETDB_INTERNAL; + return NSS_STATUS_UNAVAIL; + } net_buffer.buf = orig_net_buffer = (querybuf *) alloca (1024); @@ -166,7 +170,11 @@ _nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result, return NSS_STATUS_UNAVAIL; if (__res_maybe_init (&_res, 0) == -1) - return NSS_STATUS_UNAVAIL; + { + *errnop = errno; + *herrnop = NETDB_INTERNAL; + return NSS_STATUS_UNAVAIL; + } net2 = (u_int32_t) net; for (cnt = 4; net2 != 0; net2 >>= 8) -- cgit v1.1