* getaddrinfo and null args
@ 2015-09-22 11:40 Julien Ramseier
2015-09-25 1:04 ` Rich Felker
0 siblings, 1 reply; 2+ messages in thread
From: Julien Ramseier @ 2015-09-22 11:40 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
Hello,
According to http://pubs.opengroup.org/onlinepubs/9699919799/functions/freeaddrinfo.html:
"The nodename and servname arguments are either null pointers or pointers
to null-terminated strings. One or both of these two arguments shall be supplied
by the application as a non-null pointer. "
"[EAI_NONAME]
Neither nodename nor servname were supplied. At least one of these shall be supplied."
getaddrinfo() currently accepts both nodename and servname being null.
Following patch fixes the problem:
[-- Attachment #2: fix-getaddrinfo-both-null-args.diff --]
[-- Type: application/octet-stream, Size: 411 bytes --]
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index c88d558..d69ec98 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -20,6 +20,9 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
} sa;
} *out;
+ if (host == NULL && serv == NULL)
+ return EAI_NONAME;
+
if (hint) {
family = hint->ai_family;
flags = hint->ai_flags;
[-- Attachment #3: Type: text/plain, Size: 15 bytes --]
—
Julien
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: getaddrinfo and null args
2015-09-22 11:40 getaddrinfo and null args Julien Ramseier
@ 2015-09-25 1:04 ` Rich Felker
0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2015-09-25 1:04 UTC (permalink / raw)
To: musl
On Tue, Sep 22, 2015 at 01:40:13PM +0200, Julien Ramseier wrote:
> Hello,
>
> According to http://pubs.opengroup.org/onlinepubs/9699919799/functions/freeaddrinfo.html:
> "The nodename and servname arguments are either null pointers or pointers
> to null-terminated strings. One or both of these two arguments shall be supplied
> by the application as a non-null pointer. "
> "[EAI_NONAME]
> Neither nodename nor servname were supplied. At least one of these shall be supplied."
>
> getaddrinfo() currently accepts both nodename and servname being null.
> Following patch fixes the problem:
Thanks! Committed with minor changes for preferred style in musl.
Rich
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-25 1:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22 11:40 getaddrinfo and null args Julien Ramseier
2015-09-25 1:04 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).