summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2016-12-30 12:19:59 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2016-12-30 12:19:59 +0100
commit892932d9e23aa417f0f067cbd628868eb5bc8e48 (patch)
treeb4b1a8e41fa770e72d65006815a09c52f06aa49b
parent278bb4a6c8bd8533b611e2139cfd94dc1e135e21 (diff)
inet: fix getnameinfo problem found by new test cases
Follow documented behaviour: http://man7.org/linux/man-pages/man3/getnameinfo.3.html Sync with GNU libc behaviour.
-rw-r--r--libc/inet/resolv.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index aa81bebed..c05f18980 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1746,6 +1746,9 @@ int getnameinfo(const struct sockaddr *sa,
if (sa == NULL || addrlen < sizeof(sa_family_t))
return EAI_FAMILY;
+ if ((flags & NI_NAMEREQD) && host == NULL && serv == NULL)
+ return EAI_NONAME;
+
if (sa->sa_family == AF_LOCAL) /* valid */;
#ifdef __UCLIBC_HAS_IPV4__
else if (sa->sa_family == AF_INET) {