Re: [PATCH v3] date: detect underflow/overflow when parsing dates with timezone offset
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Jun 12, 2024, 09:07 UTC
- Message-ID
- <2c2aade1-ee83-4ea2-94ae-3d6714a52db1@gmail.com>
- In-Reply-To
- <xmqq1q58ejnw.fsf@gitster.g>
On 07/06/2024 18:40, Junio C Hamano wrote:
> "darcy via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
Show 6 quoted lines
>> +/* 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; > > I wonder if this should be of timestamp_t type instead, as the check > is done against *timestamp in parse_date_basic() where *timestamp is > of type timestamp_t to match?
I think that would make sense. We'd want to cast one of the numbers to timestamp_t to ensure that sum uses a wide enough integer as well. Using 2100L is probably OK but an explicit cast would be clearer I think.
Best Wishes
Phillip