Re: [PATCH v3] date: detect underflow/overflow when parsing dates with timezone offset
From: Karthik Nayak <hidden>
Date: 2024-06-12 09:49:25
Attachments
- signature.asc [application/pgp-signature] 690 bytes
From: Karthik Nayak <hidden>
Date: 2024-06-12 09:49:25
"darcy via GitGitGadget" [off-list ref] writes:
From: darcy <redacted> Overriding the date of a commit to be close to "1970-01-01 00:00:00" with a large enough positive timezone for the equivelant GMT time to be
s/equivelant/equivalent [snip]
diff --git a/date.c b/date.c index 7365a4ad24f..95776c8a92f 100644 --- a/date.c +++ b/date.c@@ -868,6 +868,10 @@ static int match_object_header_date(const char *date, timestamp_t *timestamp, in return 0; } + +/* 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?