git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] unpack_compressed_entry(): zlib can only process 4GB at a time

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 9, 2011, 20:12 UTC
Message-ID
<7vvcwewyq6.fsf@alter.siamese.dyndns.org>
The same theme as "unpack-objects" patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 sha1_file.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 921a216..12a166f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1643,19 +1643,24 @@ static void *unpack_compressed_entry(struct packed_git *p,
 	int st;
 	z_stream stream;
 	unsigned char *buffer, *in;
+	unsigned long bytes_to_inflate;
 
 	buffer = xmallocz(size);
 	memset(&stream, 0, sizeof(stream));
 	stream.next_out = buffer;
-	stream.avail_out = size + 1;
+	bytes_to_inflate = size + 1;
+	stream.avail_out = zlib_buf_cap(bytes_to_inflate);
 
 	git_inflate_init(&stream);
 	do {
+		unsigned char *out0 = stream.next_out;
 		in = use_pack(p, w_curs, curpos, &stream.avail_in);
 		stream.next_in = in;
 		st = git_inflate(&stream, Z_FINISH);
-		if (!stream.avail_out)
+		bytes_to_inflate -= stream.next_out - out0;
+		if (!bytes_to_inflate)
 			break; /* the payload is larger than it should be */
+		stream.avail_out = zlib_buf_cap(bytes_to_inflate);
 		curpos += stream.next_in - in;
 	} while (st == Z_OK || st == Z_BUF_ERROR);
 	git_inflate_end(&stream);
-- 
1.7.6.rc1.118.ge175b4a
Message 1 of 1 in “unpack_compressed_entry(): zlib can only process 4GB at a time”
  1. unpack_compressed_entry(): zlib can only process 4GB at a timeJunio C Hamano, Jun 9, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.