Browse Source

make getaddrinfo return error if both host and service name are null

this case is specified as a mandatory ("shall fail") error.

based on patch by Julien Ramseier.
Rich Felker 9 years ago
parent
commit
06bcf9bc94
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/network/getaddrinfo.c

+ 2 - 0
src/network/getaddrinfo.c

@@ -20,6 +20,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
 		} sa;
 	} *out;
 
+	if (!host && !serv) return EAI_NONAME;
+
 	if (hint) {
 		family = hint->ai_family;
 		flags = hint->ai_flags;