From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12452 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Dennis_W=c3=b6lfing?= Newsgroups: gmane.linux.lib.musl.general Subject: Bugs in strftime Date: Fri, 2 Feb 2018 18:07:38 +0100 Message-ID: <52570ac7-4ba2-0c7a-04b8-c1c9727a5509@gmx.de> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1517591172 1944 195.159.176.226 (2 Feb 2018 17:06:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Feb 2018 17:06:12 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 To: musl@lists.openwall.com Original-X-From: musl-return-12468-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 02 18:06:08 2018 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 1ehemP-000736-5Z for gllmg-musl@m.gmane.org; Fri, 02 Feb 2018 18:05:37 +0100 Original-Received: (qmail 27865 invoked by uid 550); 2 Feb 2018 17:07:40 -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 27827 invoked from network); 2 Feb 2018 17:07:39 -0000 Content-Language: en-US X-Provags-ID: V03:K0:WNKhhpEJtqtXu0SOpNrDoAiwx8z1GjiUF5xrR37JRh9h3F3voPU HOiug1FtuFOYOlNbipBaUVbHKwGaB9DfEpOYTdDih5kKCyy7dlS+MyNPJhYY85bA9EEYIxv N5uzpfXVEvypSPx9gvmc55MFso8VRC2A4C0Qy+82oS8IxfCnX6lxcbz1AxEbfwZke8S7KUS mrpGbbI0yU4g8Ap8hUz3w== X-UI-Out-Filterresults: notjunk:1;V01:K0:T6ghadzxwiw=:QoY1RZCa8PRVLDFEDX2wkM YXAm6G31BH39sHFXIP2IqVScMlc/0nM7Zg59Yw2E+qyuOk8bUp1dk2/b8i2msCIe5VT0se6oM uKe/11eQqrf06F9cM/t72sDkV04h3Ai7kRcvyIyUdruaRL6ljvYnw12SQxfaVmK9yWC1im7Pl 3QzPNSmS21j1Jzv0j5n/uHVJpcctNAYHULXQV7BwH7mdvx+bwqHjlHb5U4A97GdseLIiKUQR4 WkOekI0uUOUA5+VsY2mpbCJOxJBsC1Ujjy8jd8m6erG1dp1WyN1+dCh7k8Zy6+B/TKikTDmPk SlcXBbJybUgWt0BbVM8CjS1QTuv9Negm9SHJcevPI/D21eCRssUSr4ajBX1ZmMcQ2mz1/chfR OYY6qFJqMmjDo58nBLZ6m5fgWH9P3sGOTpK6CURgPbBdkPW60CzrVsuQj/9KR3z5227WCPzks LTD/toMPT2FDlfy8QsWruu5SsUlRh1iFTx4OeF/V0Hm6X2Bm5dnq0CVmh7Nhb5iXXA7PguyG8 eMJbJp0ZIRjNGe7hRDd8uYdXC/q0QF5bwdaHQHI0c5QSUNx2iSDEO8/wOT/wNShomhGDfog1O End9nUrK8n/ONlsRl6ZAxeeuAAHxw+NDCmpJulg++I1duOgsf/8b8xFZ4SbWGkuSJkgVQKQr1 sNrKJitWhGbNXTvSsV0dWYkRXakBre74wdmR10vW1hKMFKvlc3lHVadhm7w71AVI2QQ84ZYdt 4on25CiAMki0JdqXo9iZfuXl1X46kzMcsvmL540u5cnoCdKYRYvRpbKX0Opqyo5s7ot6sv4u Xref: news.gmane.org gmane.linux.lib.musl.general:12452 Archived-At: Hi, I recently wrote a test for strftime and ran it on multiple implementations. The source code of the test is available at [1]. The test results (also for other implementations) are available at [2]. On musl my test currently reports 8 failures. These are caused by two bugs: 1. For the + flag, musl does currently only prefix the output by a plus when the number without padding consumes more the 4 bytes (2 for %C). However according to the POSIX standard, there should be a leading plus when "the field being produced consumes more than four bytes" (2 for %C). The padding is part of the field being produced. So for example %+3C should always have a leading plus for any non-negative years because the field then always has a width of at least 3 bytes. (There is also an example in the POSIX standard where "%+5Y" produces "+0270" for the year 270.) This bug is causing these failures: > "%+3C": expected "+20", got "020" > "%+11F": expected "+2016-01-03", got "02016-01-03" > "%+5G": expected "+2015", got "02015" > "%+5Y": expected "+2016", got "02016" > "%+5Y": expected "+0000", got "00000" 2. %F produces incorrect results for the year 0 when a field width is specified. It seems like in this case strftime does not output the year and applies the padding to the month. This bug is causing these failures: > "%01F": expected "0-02-23", got "2-23" > "%06F": expected "0-02-23", got "002-23" > "%010F": expected "0000-02-23", got "0000002-23" The tests were run on musl 1.1.18 on Alpine Linux. [1] https://github.com/dennis95/dennix/blob/master/libc/test/test-strftime.c [2] https://gist.github.com/dennis95/b4869b5cbb3c21e15e409afb827354a5#file-musl-1-1-18-alpine-linux-x86_64