mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Clément Vasseur" <clement.vasseur@gmail.com>
To: musl@lists.openwall.com
Subject: [PATCH] getaddrinfo: fix service lookup without proto hint
Date: Tue, 11 Feb 2014 17:06:13 +0100	[thread overview]
Message-ID: <1392134773-7227-1-git-send-email-clement.vasseur@gmail.com> (raw)

Only enable the service protocol check if a protocol has been specified.
Otherwise, getaddrinfo(NULL, "tftp", NULL, &res) would return the
EAI_SERVICE error code because the protocol check was performed even
though no protocol was specified at all.
---
 src/network/getaddrinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index 5d45be7..57c53fd 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -88,7 +88,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
 				if (strncmp(line, serv, servlen) || !isspace(line[servlen]))
 					continue;
 				port = strtoul(line+servlen, &end, 10);
-				if (strncmp(end, proto==IPPROTO_UDP ? "/udp" : "/tcp", 4))
+				if (proto && strncmp(end, proto==IPPROTO_UDP ? "/udp" : "/tcp", 4))
 					continue;
 				break;
 			}
-- 
1.8.5.3



             reply	other threads:[~2014-02-11 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11 16:06 Clément Vasseur [this message]
2014-02-11 17:44 ` 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=1392134773-7227-1-git-send-email-clement.vasseur@gmail.com \
    --to=clement.vasseur@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).