From 7966331555df43bb7e2a55ce5a17a330e57f487f Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 4 Sep 2017 11:25:34 +0200 Subject: [PATCH 26] getaddrinfo: Return EAI_NODATA if gethostbyname2_r reports NO_DATA [BZ #21922] (cherry picked from commit 5f8340f583fe3d4f5734bd2371c5a45ecff2db0d) --- ChangeLog | 6 ++++++ NEWS | 1 + sysdeps/posix/getaddrinfo.c | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index c58cd5ccd0..f46bbb7c0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2017-09-01 Florian Weimer + [BZ #21922] + * sysdeps/posix/getaddrinfo.c (gaih_inet): Report EAI_NODATA error + coming from gethostbyname2_r. + +2017-09-01 Florian Weimer + * sysdeps/posix/getaddrinfo.c (gaih_inet): Only use h_errno if status indicates it is set. diff --git a/NEWS b/NEWS index 756e849643..97eb21e868 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ The following bugs are resolved with this release: [21780] posix: Set p{read,write}v2 to return ENOTSUP [21871] x86-64: Use _dl_runtime_resolve_opt only with AVX512F [21885] getaddrinfo: Release resolver context on error in gethosts + [21922] getaddrinfo with AF_INET(6) returns EAI_NONAME, not EAI_NODATA [21930] Do not use __builtin_types_compatible_p in C++ mode [21932] Unpaired __resolv_context_get in generic get*_r implementation [21941] powerpc: Restrict xssqrtqp operands to Vector Registers diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 9d9e7e2bf2..0cf87c224d 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -619,6 +619,14 @@ gaih_inet (const char *name, const struct gaih_service *service, } *pat = addrmem; } + else + { + if (h_errno == NO_DATA) + result = -EAI_NODATA; + else + result = -EAI_NONAME; + goto free_and_return; + } } else {