From: Srujith Poojary Date: Sat, 24 Oct 2026 03:44:47 GMT Subject: Re: [PATCH v2] diff-delta: use safe integer arithmetic Message-ID: In-Reply-To: On Sat, Oct 24, 2026 at 12:19 AM Junio C Hamano wrote: > > Phillip Wood writes: > > >> + 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. Hi Junio, Thank you for analyzing the struct alignment and memory allocation limits. I have updated the commit message to explain why st_mult/st_add are necessary on 32-bit platforms due to padding, as well as documenting that hsize + 1 is safe because hsize is capped at 2^26. I also fixed the code formatting using git clang-format HEAD^. Best regards, Srujith