Re: [PATCH v3] date: detect underflow/overflow when parsing dates with timezone offset
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Jun 13, 2024, 13:31 UTC
- Message-ID
- <a03cd45e-e4e0-42c7-bb98-b25cac12e42f@gmail.com>
- In-Reply-To
- <CAOLa=ZTgP+OwVrT87=og4tVdhsqjErMUJzCuT9bdDatFS=J8hQ@mail.gmail.com>
Hi Karthik
On 12/06/2024 10:49, Karthik Nayak wrote:
Show 9 quoted lines
> "darcy via GitGitGadget" <gitgitgadget@gmail.com> writes: >> + >> +/* timestamp of 2099-12-31T23:59:59Z, including 32 leap days */ >> +static const time_t timestamp_max = ((2100L - 1970) * 365 + 32) * 24 * 60 * 60 - 1; >> > > Nit: but since we're calculating the number of years here (2100L - > 1970), shouldn't we also be calculating the number of leap days instead > of hardcoding it?
I'm happy with a hard coded constant for the number of leap days - I think it is probably easier to check that (which I have done) than it would be to check the calculation as I'm not sure off the top of my head if is it safe to do (2100-1970)/4 or whether we need something more complicated.
Best Wishes
Phillip