mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Dennis Wölfing" <denniswoelfing@gmx.de>
To: musl@lists.openwall.com
Subject: Bugs in strftime
Date: Fri, 2 Feb 2018 18:07:38 +0100	[thread overview]
Message-ID: <52570ac7-4ba2-0c7a-04b8-c1c9727a5509@gmx.de> (raw)

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


             reply	other threads:[~2018-02-02 17:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 17:07 Dennis Wölfing [this message]
2018-02-05 17:51 ` Rich Felker
2018-02-06 16:10   ` Dennis Wölfing
2018-02-06 17:30     ` Rich Felker
2018-02-06 17:46   ` Rich Felker
2018-02-06 20:24     ` Dennis Wölfing
2018-02-07 20:35       ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52570ac7-4ba2-0c7a-04b8-c1c9727a5509@gmx.de \
    --to=denniswoelfing@gmx.de \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).