|
|
Message-ID: <20250820124135.GE1827@brightrain.aerifal.cx>
Date: Wed, 20 Aug 2025 08:41:35 -0400
From: Rich Felker <dalias@...c.org>
To: Khem Raj <raj.khem@...il.com>
Cc: musl@...ts.openwall.com, nsz@...t70.net
Subject: Re: [PATCH libc-test] Fix strptime on musl
On Tue, Aug 19, 2025 at 11:21:22PM -0700, Khem Raj wrote:
> musl parses the digits for %s but does not populate struct tm
> (it's "parse-only" and intentionally has no effect on tm).
> That's why you get a zeroed-out date like 1900-01-00T00:00:00.
> This is current upstream behavior:
>
> case 's': /* Parse only. Effect on tm is unspecified and presently no effect is implemented.. */
>
> musl's strptime only accepts ±hhmm for %z (e.g., -0600).
> It does not accept ±hh or ±hh:mm. So '-06' fails by design.
> It can be seen that upstream only checks 4 digits after the sign.
>
> Signed-off-by: Khem Raj <raj.khem@...il.com>
> ---
> AUTHORS | 1 +
> src/functional/strptime.c | 4 +++-
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/AUTHORS b/AUTHORS
> index cf2a394..5e78ef7 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -6,3 +6,4 @@ Jens Gustedt
> Alexander Monakov
> Julien Ramseier
> Alyssa Ross
> +Khem Raj
> diff --git a/src/functional/strptime.c b/src/functional/strptime.c
> index b5f8977..f76fa68 100644
> --- a/src/functional/strptime.c
> +++ b/src/functional/strptime.c
> @@ -109,10 +109,12 @@ int main() {
>
> /* Glibc */
> checkStrptime("1856-07-10", "%F", &tm4);
> +#ifdef __GLIBC__
> checkStrptime("683078400", "%s", &tm2);
> +#endif
> checkStrptimeTz("+0200", 2, 0);
> checkStrptimeTz("-0530", -5, -30);
> - checkStrptimeTz("-06", -6, 0);
> + checkStrptimeTz("-0600", -6, 0);
>
> return t_status;
> }
I don't think there should be conditionals on __GLIBC__ in libc-test.
If the test is asserting something that's not supposed to work per the
standard, it should be fixed not to assert that. glibc already has
their own tests of glibc-specific behaviors they want to ensure don't
regress.
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.