Thread (7 messages) 7 messages, 4 authors, 2024-06-13

Re: [PATCH v3] date: detect underflow/overflow when parsing dates with timezone offset

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]
quoted hunk ↗ jump to hunk
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?

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help