From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11012 Path: news.gmane.org!.POSTED!not-for-mail From: "A. Wilcox" Newsgroups: gmane.linux.lib.musl.general Subject: The Great Big POSIX Conformance Thread [phase 1] Date: Sun, 5 Feb 2017 17:04:43 -0600 Organization: =?UTF-8?Q?Ad=c3=a9lie_Linux?= Message-ID: <5897AF8B.9020208@adelielinux.org> 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="xstgk0t0N7F3ben81xvnTOtxMepU4jBoJ" X-Trace: blaine.gmane.org 1486335910 23476 195.159.176.226 (5 Feb 2017 23:05:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Feb 2017 23:05:10 +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-11027-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 06 00:05:04 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 1caVrk-0005qa-12 for gllmg-musl@m.gmane.org; Mon, 06 Feb 2017 00:05:04 +0100 Original-Received: (qmail 14325 invoked by uid 550); 5 Feb 2017 23:05:06 -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 14272 invoked from network); 5 Feb 2017 23:05:02 -0000 X-Enigmail-Draft-Status: N1110 Xref: news.gmane.org gmane.linux.lib.musl.general:11012 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xstgk0t0N7F3ben81xvnTOtxMepU4jBoJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello fellow muslers, I have been reading through the source tree of musl for two reasons. One is to familiarise myself with the codebase more so that I can be of better use if/when patches need to be written. The other is doing a cursory audit of POSIX conformance per XSH 2008 (2016 ed.); we at Ad=C3=A9lie are in the beginning stages of acquiring a license to the VSX-PCTS2016 test suite (which would be phase 2) and I thought it'd be prudent to find any obvious errors before obtaining it. I have found some non-conformant functions through my audit. Four are (hopefully) easy to fix; two require more thought; and one will likely need to be discussed. Easy fixes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D catopen ------- This function is not implemented, and always fails. This is [barely] legal in POSIX, but the failure must set errno. None of the errors are very appropriate (unfortunately ENOSYS is invalid); maybe ENOMEM will work. 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.1= 5-posix-getservbyport.patch if_nameindex ------------ This function always sets errno to ENOBUFS, even when the function completes succesfully. A full test case is available[2], and a suggested patch is also available[3]. [2]: https://code.foxkit.us/adelie/musl-posix/tree/master/if_nameindex [3]: https://code.foxkit.us/adelie/patches/raw/master/sys-libs/musl/musl-1.1.1= 5-if_nameindex-errno.patch pathconf -------- This function does not provide a reference for timestamp resolution. See the POSIX reference[4] for more information. This should be easy to fix. [4]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html#ta= g_13_77_03_03 Further thought required =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D confstr ------- musl returns the empty string ("") for options where it does not have any values. The POSIX standard states[5] that if an option is recognised but does not have a value, errno should not be set and NULL should be returned. [5]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html getlogin -------- musl simply returns getenv("LOGNAME"). getlogin(3) is used to determine the login name of the controlling terminal for the process. In addition to getenv("LOGNAME") being improper behaviour (since getlogin(3) could be used within a su or sudo-run shell), it also causes both coreutils and busybox logname(1) to break conformance: ``` awilcox on ciall ~ $ su Password: ciall ~ # LOGNAME=3Dhelloworld logname helloworld ``` The correct behaviour is shown here on glibc: ``` awilcox on ciall [pts/16 Sun 5 16:51] ~: su Password: ciall awilcox # LOGNAME=3Dhelloworld logname awilcox ``` The POSIX standard states that implementations generally check the terminal of fds 0/1/2, then fall back to /dev/tty.[6] [6]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html Discussion required =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D getdate ------- The musl implementation of getdate(3)[7] sets getdate_err to 7 for any of the reasons that it should set to 5 (I/O error while reading template file - i.e., fgets fails), 7 (there is no line in the template that matches the input), or 8 (invalid input specification)[8]. While I realise musl will probably never implement all conditions that could provide error condition 8, I feel that error condition 5 should at least be implemented. Something as simple as if (ferror(f)) getdate_err =3D 5; else getdate_err =3D 7; could suffice, IMO. However= , it would be nice to see better, more robust error handling for condition 8 as well. [7]: http://git.musl-libc.org/cgit/musl/tree/src/time/getdate.c#n32 [8]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getdate.html Best regards, --arw --=20 A. Wilcox (awilfox) Project Lead, Ad=C3=A9lie Linux http://adelielinux.org --xstgk0t0N7F3ben81xvnTOtxMepU4jBoJ 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 iQIcBAEBCAAGBQJYl6+MAAoJEMspy1GSK50U428QAM5ol1AtR5oeHZL9oChKbnWI DgaF9y12WezG0PJ31OTKiCa+gCx95732w4LWrzNzNGPgWfEkcAT6TcN5CKkx/G2w hq+Ix3BXtvdCHt4fSSIIcgVjUFRW3xWsAg1Z/vHsrndYqlyxsb66AQH+uLfDn3o7 ePKVd6hw/yqX2XPvojF2uygjPvTueMexiu4t38Sgpj1r8OYJbCkY8OoLdzeJLGmC mGahcc2bWM6d2JGQi2xrgjpt5N5BYIyiMzeWtgFg9ECLERFQGw//lfYvdtVJLTQo WXv8B6Vih+yO+mxm23vg0lxittXRES8CqG3QFp9Y5IrYW34P4NTmzdXap6pqrK7e 2Z9Wus9nHc38HTXTZ2eHJgrNVjoW0Kxv9HK+0dGWBVK6Pnct8yjnQm+1IwGMqJyf 9fcqQcmnlVuVyrBy8DBugDaOpLXPT3v0cH796BjUw+qV7y1lAg26h7ERosmOoU3U 4pwLRMynIfl5LLpdC+2kq3tuoveQVe0wmgCvEcaeVYlQmcm3QFMQSovpnj77TMpH Q02eVaG3eNFkwrdG6zOOtRaY4c3NDWMHmIl303KKupH+z1VJC46Tz3Y1P9Scs+Zm sjN7hCYDOfibFFVlGeSu8D/zs7Pd27yXSPE3LT+UINZEhgsHxIH7LxqHQi0w4IU/ Zs440lwcR99ql6SdvGkk =umC9 -----END PGP SIGNATURE----- --xstgk0t0N7F3ben81xvnTOtxMepU4jBoJ--