mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Julien Ramseier <j.ramseier@gmail.com>
To: musl@lists.openwall.com
Subject: getaddrinfo and null args
Date: Tue, 22 Sep 2015 13:40:13 +0200	[thread overview]
Message-ID: <2190F767-A1C5-4ED9-8575-FF55565B8317@gmail.com> (raw)

[-- 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

             reply	other threads:[~2015-09-22 11:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 11:40 Julien Ramseier [this message]
2015-09-25  1:04 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2190F767-A1C5-4ED9-8575-FF55565B8317@gmail.com \
    --to=j.ramseier@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).