sha1_file: correct zlib buffer handlinggirocco/v2.11.4+
commit93502c76a0089d6a90530f48de597a4a6acc3550
authorJeremy Linton <lintonrjeremy@gmail.com>
Wed, 13 Jun 2018 14:22:07 +0000 (13 09:22 -0500)
committerKyle J. McKay <mackyle@gmail.com>
Sun, 5 Apr 2020 04:16:24 +0000 (4 21:16 -0700)
tree61c70f38fb72f9b8dfb7823fcf8d106ce8bc56a4
parent87cdb88fa7562b3796a4e1a4b19f44b842874427
sha1_file: correct zlib buffer handling

The buffer being passed to zlib includes a NUL terminator that git
needs to keep in place. unpack_compressed_entry() attempts to detect
the case that the source buffer hasn't been fully consumed by
checking to see if the destination buffer has been over consumed.

This causes a problem, that more recent zlib patches have been
poisoning the unconsumed portions of the buffer which overwrites
the NUL byte, while correctly returning length and status.

Let's place the NUL at the end of the buffer after inflate returns
to assure that it doesn't result in problems for git even if its
been overwritten by zlib.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c