make getaddrinfo return error if both host and service name are null
authorRich Felker <dalias@aerifal.cx>
Fri, 25 Sep 2015 01:01:11 +0000 (01:01 +0000)
committerRich Felker <dalias@aerifal.cx>
Fri, 25 Sep 2015 01:03:36 +0000 (01:03 +0000)
this case is specified as a mandatory ("shall fail") error.

based on patch by Julien Ramseier.

src/network/getaddrinfo.c

index c88d558c49811d249690eeffdf75a2ed9c5c7b4e..b9439f776fcebf41e00ed1e6fff674b7a42ea1be 100644 (file)
@@ -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;