Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <-44SZR0LbVoyD5lp_9VrAFnIjGNbDvibCVUYEprqMToPidjopTHM4aLZuhjomrGJtvpGrc_gjrgK6roKWwunjEkk1y-BKRhtlGpWjnslQNA=@pm.me>
Date: Sat, 23 Mar 2024 16:54:53 +0000
From: Alexander Weps <exander77@...me>
To: musl@...ts.openwall.com
Cc: Markus Wichmann <nullplan@....net>
Subject: Re: Broken mktime calculations when crossing DST boundary

One of the main purposes of struct tm is to calculate date and time, by adding and substracting it's fields.

> mktime cannot tell whether your non-normalized input was the result of
> you starting with 01:00:02 and adding 1 hour (in which case, our
> output does not reflect your intent) or of you starting with 3:00:02
> and subtracting 1 hour (in which case, our output does reflect your
> intent).

We are not adding hours here, your example is completely unrelated.

We are adding or subtracting minutes that changes hours.

tm_sec: 2
tm_min: 60
tm_hour: 1

vs

tm_sec: 2
tm_min: 0
tm_hour: 2

And:

tm_sec: 2
tm_min: 59
tm_hour: 1

vs

tm_sec: 2
tm_min: -1
tm_hour: 2

AW


On Saturday, March 23rd, 2024 at 16:31, Rich Felker <dalias@...c.org> wrote:

> On Sat, Mar 23, 2024 at 01:49:48PM +0000, Alexander Weps wrote:
>
> > I don't think time can go backwards by incrementing field under any conditions.
> >
> > Going from:
> > tm_sec: 2
> > tm_min: 60
> > tm_hour: 1
> > tm_mday: 31
> > tm_mon: 2
> > tm_year: 124
> > tm_wday: 0
> > tm_yday: 90
> > tm_isdst: -1
> >
> > To:
tm_sec: 1
tm_min: 59
tm_hour: 2
> > tm_sec: 2
> > tm_min: 0
> > tm_hour: 1
> > tm_mday: 31
> > tm_mon: 2
> > tm_year: 124
> > tm_wday: 0
> > tm_yday: 90
> > tm_isdst: 0
> >
> > Seems to be plain wrong. I cannot come up with any argument for this
> > being correct under any conditions.
>
>
> The above broke-down time is 2:00:02, which does not exist on that day
> as a normalized time. If interpreted as non-DST, it would be just a
> couple seconds past the end of non-DST (1:59:59.99999..). If
> interpreted as DST, it would be just under an hour before the start of
> DST (3:00:00), which, after normalization, is 1:00:02 non-DST.
>
> mktime cannot tell whether your non-normalized input was the result of
> you starting with 01:00:02 and adding 1 hour (in which case, our
> output does not reflect your intent) or of you starting with 3:00:02
> and subtracting 1 hour (in which case, our output does reflect your
> intent).
>
> > mktime was given a struct tm with uncertain STD/DST, it deduced it
> > is STD and then thrown away 60 minute information. The minutes got
> > reset from 60 to 0 and no other change was done.
>
>
> It did not deduce it was STD. It deduced it was non-normalized DST
> rather than non-normalized STD (this is an arbitrary choice), then
> normalized it and got STD.
>
> 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.