From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4569 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] getaddrinfo: fix service lookup without proto hint Date: Tue, 11 Feb 2014 12:44:31 -0500 Message-ID: <20140211174431.GA15627@brightrain.aerifal.cx> References: <1392134773-7227-1-git-send-email-clement.vasseur@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1392140677 9545 80.91.229.3 (11 Feb 2014 17:44:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Feb 2014 17:44:37 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4573-gllmg-musl=m.gmane.org@lists.openwall.com Tue Feb 11 18:44:46 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 1WDHO1-0006RB-HD for gllmg-musl@plane.gmane.org; Tue, 11 Feb 2014 18:44:45 +0100 Original-Received: (qmail 3311 invoked by uid 550); 11 Feb 2014 17:44:43 -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 3303 invoked from network); 11 Feb 2014 17:44:43 -0000 Content-Disposition: inline In-Reply-To: <1392134773-7227-1-git-send-email-clement.vasseur@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4569 Archived-At: On Tue, Feb 11, 2014 at 05:06:13PM +0100, Clément Vasseur wrote: > 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; Anyone else have comments on this? My concern was that we don't yet support returning both tcp and udp serices when proto is unspecified, and so doing something like this could prevent finding the (presumed important) tcp service if the (usually nonsensical duplicate) udp service happened to come first in the services file. But if all real-world services files have the tcp services first, it probably doesn't matter, and this patch is probably ok. With the upcoming (post-1.0) resolver overhaul, this will be a non-issue since we'll be able to return both easily. Rich