git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] packfile: Correct zlib buffer handling
@ 2018-06-13 14:22 Jeremy Linton
  2018-06-13 17:21 ` Eric Sunshine
  0 siblings, 1 reply; 7+ messages in thread
From: Jeremy Linton @ 2018-06-13 14:22 UTC (permalink / raw)
  To: git; +Cc: jonathantanmy, gitster, Jeremy Linton

The buffer being passed to zlib includes a null 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 null, while correctly returning length and status.

Let's replace the null at the end of the buffer to assure that
if its been overwritten by zlib it doesn't result in problems for
git.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
---
 packfile.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/packfile.c b/packfile.c
index 7c1a2519f..8db5d90ca 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1433,6 +1433,8 @@ static void *unpack_compressed_entry(struct packed_git *p,
 		return NULL;
 	}
 
+	buffer[size] = 0; /* assure that the buffer is still terminated */
+
 	return buffer;
 }
 
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-13 21:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13 14:22 [PATCH v2] packfile: Correct zlib buffer handling Jeremy Linton
2018-06-13 17:21 ` Eric Sunshine
2018-06-13 18:32   ` Junio C Hamano
2018-06-13 18:40     ` Eric Sunshine
2018-06-13 18:38   ` Junio C Hamano
2018-06-13 21:48     ` Jeremy Linton
2018-06-13 21:56       ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).