Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <n2-QRxWwwx1FveQe6AaxCTpCjO6wJxilEw38V4yZIOmEmXUR6Xc3nEuwkUwVZZ4iQT8hlDa0uDbu3YyLS_NnIE9bZWNvjtqZBLrOwCiGljo=@pm.me>
Date: Mon, 25 Mar 2024 20:05:50 +0000
From: Alexander Weps <exander77@...me>
To: musl@...ts.openwall.com
Subject: Re: Broken mktime calculations when crossing DST boundary

Sorry my bad, that was isdst = 0;

$  gcc foo.c -o foo && TZ=Pacific/Apia ./foo
before: 2011-12-31 00:00:00 +14 0
after1: 2011-12-31 00:00:00 +14 1325239200
after2: 2011-12-30 00:00:00 +14 -1
after3: 2011-12-31 00:00:00 +14 1325239200

$  musl-gcc foo.c -o foo && TZ=Pacific/Apia ./foo
before: 2011-12-31 00:00:00  0
after1: 2011-12-31 00:00:00 +14 1325239200
after2: 2011-12-29 00:00:00 -10 1325152800
after3: 2011-12-29 00:00:00 -10 1325152800

I agree with isdst = 1; reuslts.

AW


On Monday, March 25th, 2024 at 20:47, Rich Felker <dalias@...c.org> wrote:

> On Mon, Mar 25, 2024 at 03:38:13PM -0400, Rich Felker wrote:
>
> > On Mon, Mar 25, 2024 at 06:57:49PM +0000, Alexander Weps wrote:
> >
> > > I am not sure which one you mean, all latest codes even includes
> > > headers and main...
> >
> > https://www.openwall.com/lists/musl/2024/03/25/3
> >
> > > I have no idea what to tell you.
> >
> > The first version I found that's actually compilable is:
> >
> > https://www.openwall.com/lists/musl/2024/03/25/11
> >
> > It roughly behaves as expected on musl, except possibly not applying
> > the tm_isdst=0, which is what was making the output confusing on
> > glibc -- that threw the input back across the rule change cutoff.
>
>
> No, it's deeper than this. glibc is offsetting the input by an entire
> day when tm_isdst=0, and I don't know why. It looks like a bug in
> glibc.
>
> > With tm_isdst=1 and tm_mday=31, on glibc, I get:
> >
> > before: 2011-12-31 00:00:00 WSDT 0
> > after1: 2011-12-31 00:00:00 WSDT 1325239200
> > after2: 2011-12-30 00:00:00 WSDT -1
> > after3: 2011-12-31 00:00:00 WSDT 1325239200
> >
> > The -1 in the after2 line indicates that mktime failed with an error
> > (and should not have modified tm; that's arguably a bug in glibc). The
> > partial modification that it made reflects the initial normalization
> > (type 1 in my notation) but not the rule change normalization (type 2
> > in my notation) since glibc has failed the operation for an input date
> > that does not exist on the calendar (it does not do type 2
> > normalization at all; it just rejects it).
> >
> > Running this same change on musl, I get:
> >
> > before: 2011-12-31 00:00:00 0
> > after1: 2011-12-31 00:00:00 +14 1325239200
> > after2: 2011-12-29 00:00:00 -10 1325152800
> > after3: 2011-12-29 00:00:00 -10 1325152800
> >
> > which again is what I expect. From one side, the move-by-1-day changes
> > the time to the next calendar day in that direction. From the other
> > side, it's unable to change it.
> >
> > I'll look into why the tm_isdst=0 application was not happening.
>
>
> Hmm, I must have misread the output. It seems to be correct with
> tm_isdst=0 too:
>
> before: 2011-12-31 00:00:00 0
> after1: 2011-12-31 01:00:00 +14 1325242800
> after2: 2011-12-29 01:00:00 -10 1325156400
> after3: 2011-12-29 01:00:00 -10 1325156400
>
> (If it's 00:00:00 in standard time, it's 01:00:00 in DST, so the
> initial time seems to have been interpreted correctly.)
>
> I also went back and tested both with tm_isdst=-1, and both glibc and
> musl do the same thing as they do with tm_isdst=1 (which is correct).
>
> 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.