From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11018 Path: news.gmane.org!.POSTED!not-for-mail From: "A. Wilcox" Newsgroups: gmane.linux.lib.musl.general Subject: Re: The Great Big POSIX Conformance Thread [phase 1] Date: Mon, 6 Feb 2017 16:25:29 -0600 Organization: =?UTF-8?Q?Ad=c3=a9lie_Linux?= Message-ID: <5898F7D9.7090403@adelielinux.org> References: <5897AF8B.9020208@adelielinux.org> <20170206000100.GX1533@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="satniOengDTOltePT0GnvPTqAh11OlP3b" X-Trace: blaine.gmane.org 1486419957 26415 195.159.176.226 (6 Feb 2017 22:25:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Feb 2017 22:25:57 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 To: musl@lists.openwall.com Original-X-From: musl-return-11033-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 06 23:25:53 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1carjM-0006hm-Uj for gllmg-musl@m.gmane.org; Mon, 06 Feb 2017 23:25:53 +0100 Original-Received: (qmail 22449 invoked by uid 550); 6 Feb 2017 22:25:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 22431 invoked from network); 6 Feb 2017 22:25:55 -0000 X-Enigmail-Draft-Status: N1110 In-Reply-To: <20170206000100.GX1533@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:11018 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --satniOengDTOltePT0GnvPTqAh11OlP3b Content-Type: multipart/mixed; boundary="------------010208000906040602060408" This is a multi-part message in MIME format. --------------010208000906040602060408 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/02/17 18:01, Rich Felker wrote: > On Sun, Feb 05, 2017 at 05:04:43PM -0600, A. Wilcox wrote: >> getservbyport >> ------------- >> >> Non-conformance of this function was discussed on IRC. Rich Felker >> had said he would apply the patch I wrote[1], but it has not been >> applied yet. If there is an issue with said patch, please let me know= >> so that I may fix it. >> >> >> [1]: >> https://code.foxkit.us/adelie/patches/raw/master/sys-libs/musl/musl-1.= 1.15-posix-getservbyport.patch >=20 > This patch probably needs to be checked better still. Knowing the > legaycy get*by*_r interfaces, I suspect it's invalid to return without > setting *res to something. Also it might be better to just check > earlier (at the top) if the argument parses as a number, and bail > immediately, rather than first doing all the work then throwing the > result away. In addition to my earlier comments in my last mail, I have found a standard definition for getservbyport_r[1] and it states that on error, *res shall be set to NULL. The function does this at the start[2], so I think this patch should be conformant. [1]: http://refspecs.linux-foundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-= generic/baselib-getservbyport-r.html [2]: http://git.musl-libc.org/cgit/musl/tree/src/network/getservbyport_r.c#n23= Best, --arw --=20 A. Wilcox (awilfox) Project Lead, Ad=C3=A9lie Linux http://adelielinux.org --------------010208000906040602060408 Content-Type: text/x-patch; name="0001-getservbyport_r-return-ENOENT-if-service-not-found.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-getservbyport_r-return-ENOENT-if-service-not-found.patc"; filename*1="h" =46rom 3579f8840d48f7cabc303d480673d5de72b3c757 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 6 Feb 2017 16:12:21 -0600 Subject: [PATCH] getservbyport_r: return ENOENT if service not found getnameinfo will return the numeric form of the service if it has no name. This is conformant behaviour for getnameinfo, but not for getservbyport{,_r}. NFS for Linux and some BitTorrent clients use getservbyport(3) to check if a port has an IANA reservation before using it for port mapping. With the present behaviour, these packages (and assumedly others) fail to ever find a free port, and refuse to start (or in the case of NFS, simply refuse any connections). This patch solves the conformance issue for getservbyport *and* getservbyport_r (since the first calls in to the second in musl). Signed-off-by: A. Wilcox --- src/network/getservbyport_r.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/getservbyport_r.c b/src/network/getservbyport_r.= c index a0a7cae..37a001b 100644 --- a/src/network/getservbyport_r.c +++ b/src/network/getservbyport_r.c @@ -5,6 +5,7 @@ #include #include #include +#include =20 int getservbyport_r(int port, const char *prots, struct servent *se, char *buf, size_t buflen, struct servent **res) @@ -50,6 +51,7 @@ int getservbyport_r(int port, const char *prots, break; } =20 + if (strtol(buf, 0, 10)=3D=3Dntohs(port)) return ENOENT; *res =3D se; return 0; } --=20 2.10.0 --------------010208000906040602060408-- --satniOengDTOltePT0GnvPTqAh11OlP3b Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYmPfZAAoJEMspy1GSK50UYBgP/2+3Bs02W5LJlKuFxvgkFACA 4qh9QqHO5PYJKa9pm8DPs7g1iWC+81bOet9zTyZbDDiYsxV1wpNQT7PlrQmwcYF6 6G6R5vJ5XkBAa1VlAE/auRnPMfigaWhwygMD2rMnYbr/H0FOA0gUQSoJFQRXvW3L JyCQsCNlt/BJt7yhLIKKeHNuS89WiclasJjJQOrR8QqhNRecE/eJsOQXjb8gBJ8o F0+nDaNo9ZB2o2a6Ng6Oz+USiqRiBsJBWV0lCTJ/QuW81B3Q5RZnXYAVvqopqLwT 82l3ywqjfa42Y13AB53HUFmXcKQXU+RBjR64F+fsuH9+Ba+dXpOoPY5AlXLl3MaW Bj5Knl+xc3X+4oN2Y4u+Glo07fyCwPITifjy7eWkGoblBuvDSeHs6IrRtaTCF0g5 2AMmIufu5jXt5q7yek9rpcJbQq7D36rkcd4+guG2R9WSkNhCmfbw3qGGrtdD0VVe jeyzu8QlZvlYcupu5gQkZ7LxecQpujj1pH4Gzs7BiNe9hA57EqtiiEEkfMDg2cuW /YGOUp+jx6LBiMPBHJ4AzHjZsk3ojKO2W45tC4VZ+jHMfSzvzjwJegkej9CFT4TR EvmEkGG3G+ZEjDRFl4IsReVSvcOVwgVY1iBtYbZ+9mZ8N7NcSLc/xZgqBVq+HEaW pKtA3gtR9xLANxD3NSFl =Kdey -----END PGP SIGNATURE----- --satniOengDTOltePT0GnvPTqAh11OlP3b--