Browse Source

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.
Waldemar Brodkorb 8 years ago
parent
commit
892932d9e2
1 changed files with 3 additions and 0 deletions
  1. 3 0
      libc/inet/resolv.c

+ 3 - 0
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) {