Re: [PATCH v2] diff-delta: use safe integer arithmetic
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 23, 2026, 18:49 UTC
- Message-ID
- <xmqq8q3o5k1q.fsf@gitster.g>
- In-Reply-To
- <fe3d651a-d1af-47a7-9b7b-a4ff242ca303@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 6 quoted lines
>> + memsize = st_add3(sizeof(*index), >> + st_mult(sizeof(*packed_hash), hsize + 1), > > What are the bounds of hsize? Can adding one to it overflow? The > alignment is off here as well, all the arguments to st_add3() should be > aligned.
Very good question, and I think hsize is capped at 1^26 in a code early in this function, which makes this safe. It needs to be explained why it is safe in the log message, though.