Download raw body.
reuse deltas while packing
On Mon, 07 Feb 2022 15:32:10 +0100, Stefan Sperling wrote: > This patch fixes got-index-pack getting stuck. > > Unfortunately, zlib uses an unsigned int to represent the number of > input bytes available in its input buffer, instead of a size_t. > > Large mapped files can cause truncation during our assignment from > size_t to unsigned int when we update zlib's input length counter. > This results in z->avail_in being set to zero, even though plenty > of bytes are available for zlib to consume. We then loop forever > asking zlib to decompress another zero bytes during every iteration. Since the problem occurs when len - *consumed > UINT_MAX wouldn't something like this be a little better? const size_t avail = len - *consumed; z->avail_in = MIN(avail, UINT_MAX); That way the entire UINT_MAX is available. Or if you prefer the if() style: if (len - *consumed > UINT_MAX) z->avail_in = UINT_MAX; else z->avail_in = len - *consumed; There should be no need to cast UINT_MAX to size_t since it is explicitly unsigned and should be implicitly promoted to size_t for the comparison. - todd
reuse deltas while packing