From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4568 Path: news.gmane.org!not-for-mail From: =?UTF-8?q?Cl=C3=A9ment=20Vasseur?= Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] getaddrinfo: fix service lookup without proto hint Date: Tue, 11 Feb 2014 17:06:13 +0100 Message-ID: <1392134773-7227-1-git-send-email-clement.vasseur@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1392138242 10329 80.91.229.3 (11 Feb 2014 17:04:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Feb 2014 17:04:02 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4572-gllmg-musl=m.gmane.org@lists.openwall.com Tue Feb 11 18:04:09 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WDGki-0000kr-SE for gllmg-musl@plane.gmane.org; Tue, 11 Feb 2014 18:04:08 +0100 Original-Received: (qmail 5652 invoked by uid 550); 11 Feb 2014 17:04:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30710 invoked from network); 11 Feb 2014 16:06:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=R/FXYqYNmkJt3b0QEI/kZnMYUHaHCbNLLb0+8nG84os=; b=X4L3DznHDnY3Hxx4wDn0OmYLe4ZT5htw/QpGbKDZvuSaTZcmvvLBXXkpsJr9C4XoyV b11mle4eeS0wnHf9hsm/4ETPa/P1QIYfwqUmucXnNsmeJWqJZJ0qWh3npcHP0CdDa+qB PGzG1vkhIontJN+KGS0Nj1wDUDLapWyHib0+puwfWwM7h92l2grScp0QEJp+ekSEh+Sy HAuoKTRKh5plbJWQkWjncNo6+9c3IYlVxeJqHBgok8s0K5TAgpKV+35Om2MWPK6U2zUz tuXr7BMjs117DHDRW0OSeeANlv7mq3L8wDE9jk0WPxR5LdQO1ufykDDGRoVgtRxQ6Vye p3+Q== X-Received: by 10.152.42.129 with SMTP id o1mr27205203lal.19.1392134776269; Tue, 11 Feb 2014 08:06:16 -0800 (PST) X-Mailer: git-send-email 1.8.5.3 Xref: news.gmane.org gmane.linux.lib.musl.general:4568 Archived-At: 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