Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 8 May 2014 18:42:36 +0200
From: Szabolcs Nagy <>
Subject: Re: strptime problems

* Rich Felker <> [2014-05-08 00:32:14 -0400]:
> to get it done now. However I'm not clear on what the behavior of
> strptime should be when reading "derived" fields that don't actually
> correspond to anything in the "struct tm". Should it just parse and
> ignore them, or should it somehow convert back? The week-based-year
> stuff is probably the biggest question but there are others too.

strptime seems to be underspecified, it's not clear what happens
in case of inconsistent input, what tm_* fields should be filled
out, etc

glibc sets tm.tm_wday when it can be calculated, musl doesn't

glibc sets __tm_gmtoff so strptime depends on the current tz setting

glibc supports %s in strptime (non-posix), musl doesn't

in musl invalid format strings don't fail now

in the numeric_range logic i think a <= can be changed into <

--- a/src/time/strptime.c
+++ b/src/time/strptime.c
@@ -138,10 +138,12 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
                case '%':
                        if (*s++ != '%') return 0;
+               default:
+                       return 0;
                        if (!isdigit(*s)) return 0;
                        *dest = 0;
-                       for (i=1; i<=min+range && isdigit(*s); i*=10)
+                       for (i=1; i<min+range && isdigit(*s); i*=10)
                                *dest = *dest * 10 + *s++ - '0';
                        if (*dest - min >= (unsigned)range) return 0;
                        *dest -= adj;

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.