git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] xdiff: avoid arithmetic overflow in xdl_get_hunk()

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 16, 2025, 19:53 UTC
Message-ID
<xmqqiko8da63.fsf@gitster.g>
In-Reply-To
<8c9a3966-2746-4619-9f77-ca95797dcab8@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 12 quoted lines
> Am 14.03.25 um 23:28 schrieb Junio C Hamano:
>> René Scharfe <l.s.r@web.de> writes:
>>
>>>  t/t4055-diff-context.sh | 10 ++++++++++
>>>  xdiff/xemit.c           |  8 +++++++-
>>>  2 files changed, 17 insertions(+), 1 deletion(-)
>>
>> Oh, I love a patch like this that is well thought out to carefully
>> check the bounds, instead of blindly say "ah, counting number of
>> things in size_t solves everything" ;-)
>
> Converting xdiff from long to size_t is still a good idea, I think, ...

Oh, no question about that, especially if the number of counted things are somehow proportionally related to the size of in-core memory regions in any way.

What I do *not* like is the recent trend in the patches I see. They stop thinking there once they blindly replace int or unsigned or whatever with size_t and the compiler stops warning. Even though compiler warnings can be a useful tool when there is very little false positives, they are merely tools to improve the code, but I see more and more confused patches that seem to think squelching warnings is the goal in itself, without thinking if the resulting code is actually improved.

And I didn't see that in this patch. The patch was actually written with real goal of improving the code in mind.

> but
> would be lot more effort and thus more risky.  
Perhaps, perhaps not.
> Comparisons to upstream
> would become a lot more noisy as well.

I am not sure how much of that matters these days, though. Are they still active, or is the code perfect and pretty much done? I somehow had the impression it has been the latter for a long time...

Thanks.
Previous: René ScharfeNext: René Scharfe
Message 5 of 7 in “Iffy output given git diff --unified=2147483647”
  1. Jason ChoMar 12, 2025
  2. xdiff: avoid arithmetic overflow in xdl_get_hunk()René Scharfe, Mar 14, 2025
  3. Junio C HamanoMar 14, 2025
  4. René ScharfeMar 15, 2025
  5. Junio C HamanoMar 16, 2025
  6. René ScharfeMar 17, 2025
  7. Jason ChoMar 14, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.