]> git.ipfire.org Git - thirdparty/git.git/commit
zlib: properly clamp to uLong
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 18 Jun 2026 13:50:18 +0000 (13:50 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Jun 2026 16:46:56 +0000 (09:46 -0700)
commitab3810eb6fffd95d39e9579945e360e8247eeda8
tree1ab0403733a3fe95c644a10f799d233168848fa3
parent7a094d68a27e321a99c8ab6b700909e503904bd9
zlib: properly clamp to uLong

On platforms where `unsigned long` and `size_t` differ in bit size, we
want to clamp the buffers we pass to zlib to the former's size, as per
d05d666977 (git-zlib: handle data streams larger than 4GB, 2026-05-08).

The logic introduced in that commit performs a clamping to the bits,
though, which fails to do what is needed here: If too many bytes are
available in the buffers, we need to clamp to the maximum value of an
`unsigned long`. Otherwise, we ask zlib to use too small buffers, in the
worst case using 0 as the size (think: a value whose 32 lowest bits are
all zero).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-zlib.c