Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240323153146.GS4163@brightrain.aerifal.cx>
Date: Sat, 23 Mar 2024 11:31:46 -0400
From: Rich Felker <dalias@...c.org>
To: Alexander Weps <exander77@...me>
Cc: musl@...ts.openwall.com, Markus Wichmann <nullplan@....net>
Subject: Re: Broken mktime calculations when crossing DST boundary

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: 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.