public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail•com>
To: darcy <acednes@gmail•com>,
	phillip.wood@dunelm•org.uk, Junio C Hamano <gitster@pobox•com>,
	darcy via GitGitGadget <gitgitgadget@gmail•com>
Cc: git@vger•kernel.org, Patrick Steinhardt <ps@pks•im>,
	Jeff King <peff@peff•net>
Subject: Re: [PATCH v2] date: detect underflow when parsing dates with positive timezone offset
Date: Wed, 5 Jun 2024 14:10:23 +0100	[thread overview]
Message-ID: <7ae05b6a-fb63-4ec7-8006-e968862cc5c7@gmail.com> (raw)
In-Reply-To: <4574e410-ca1a-495f-9835-14ee3fa454a1@gmail.com>

On 04/06/2024 09:48, darcy wrote:
> On 4/6/24 00:13, Phillip Wood wrote:
> 
>> Hi darcy
>> On 03/06/2024 12:44, darcy wrote:
>>>> Do we also want to check for overflows in the other direction (a large
>>>> timestamp with a negative timezone offset)?
>>> Is this something people want added? I am happy to implement this if
>>> so, though it wasn't my original intention.
>> I think if we're worried about the date overflowing in one direction it
>> makes sense to fix overflows in the other direction at the same time
>> especially as I think that the other case involves a signed integer
>> overflow which is undefined behavior in C.
> 
> That makes sense.
> 
> Though I am reading the `tm_to_time_t` code now and it only allows years
> up to 2099.
> 
>>     if (year < 0 || year > 129) /* algo only works for 1970-2099 */
>>         return -1;

Thanks for taking a closer look, I wasn't aware of that. Reading Peff's 
reply it seems like timestamp is actually unsigned and as we limit the 
maximum year to 2099 it seems unlikely we'll overflow from too larger 
date after all.

Best Wishes

Phillip

> I can of course add a check here for dates close to the end of 2099, but
> it seems that the bigger issue is that some day people will want to use
> Git after 2099... Should I see if I can extend this range? I'm not sure
> where that specific year comes from, it doesn't seem to be based on a
> limit of the size of `time_t`, and the comment or git logs don't seem to
> provide a reason.
> 
> 


  parent reply	other threads:[~2024-06-05 13:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27  9:17 [PATCH] fix: prevent date underflow when using positive timezone offset darcy via GitGitGadget
2024-05-28 14:05 ` Patrick Steinhardt
2024-05-28 14:49   ` Phillip Wood
2024-05-28 17:06   ` Junio C Hamano
2024-06-02 23:06 ` [PATCH v2] date: detect underflow when parsing dates with " darcy via GitGitGadget
2024-06-03 11:13   ` Junio C Hamano
2024-06-03 11:44     ` darcy
2024-06-03 14:13       ` Phillip Wood
2024-06-04  8:48         ` darcy
2024-06-04  9:33           ` Jeff King
2024-06-05  6:52             ` darcy
2024-06-05 13:10           ` Phillip Wood [this message]
2024-06-05 17:27             ` Junio C Hamano
2024-06-06  4:56               ` darcy
2024-06-07  0:17   ` [PATCH v3] date: detect underflow/overflow when parsing dates with " darcy via GitGitGadget
2024-06-07 17:40     ` Junio C Hamano
2024-06-08 18:58       ` Junio C Hamano
2024-06-14  1:20         ` Junio C Hamano
2024-06-15 11:47           ` Karthik Nayak
2024-06-11 23:30       ` Junio C Hamano
2024-06-11 23:49         ` rsbecker
2024-06-11 23:52           ` Junio C Hamano
2024-06-25 23:12         ` [PATCH v4 0/2] Darcy's "date underflow fix" topic, final reroll Junio C Hamano
2024-06-25 23:12           ` [PATCH v4 1/2] t0006: simplify prerequisites Junio C Hamano
2024-06-25 23:30             ` Eric Sunshine
2024-06-26  0:04               ` Junio C Hamano
2024-06-25 23:12           ` [PATCH v4 2/2] date: detect underflow/overflow when parsing dates with timezone offset Junio C Hamano
2024-06-26 15:21           ` [PATCH v4 0/2] Darcy's "date underflow fix" topic, final reroll Phillip Wood
2024-06-26 18:32             ` Junio C Hamano
2024-06-12  9:07       ` [PATCH v3] date: detect underflow/overflow when parsing dates with timezone offset Phillip Wood
2024-06-12  9:49     ` Karthik Nayak
2024-06-13 13:31       ` Phillip Wood
2024-06-13 16:16         ` Junio C Hamano
2024-06-14 20:09           ` Karthik Nayak
2024-06-14 21:02             ` Junio C Hamano
2024-06-15 11:49               ` Karthik Nayak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ae05b6a-fb63-4ec7-8006-e968862cc5c7@gmail.com \
    --to=phillip.wood123@gmail$(echo .)com \
    --cc=acednes@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitgitgadget@gmail$(echo .)com \
    --cc=gitster@pobox$(echo .)com \
    --cc=peff@peff$(echo .)net \
    --cc=phillip.wood@dunelm$(echo .)org.uk \
    --cc=ps@pks$(echo .)im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox