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

[PATCH v2] packfile: Correct zlib buffer handling

From
Jeremy Linton <lintonrjeremy@gmail.com>
Date
Jun 13, 2018, 14:22 UTC
Message-ID
<20180613142207.14385-1-lintonrjeremy@gmail.com>

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
Next: Eric Sunshine
Message 1 of 7 in “packfile: Correct zlib buffer handling”
  1. packfile: Correct zlib buffer handlingJeremy Linton, Jun 13, 2018
  2. Eric SunshineJun 13, 2018
  3. Junio C HamanoJun 13, 2018
  4. Eric SunshineJun 13, 2018
  5. Junio C HamanoJun 13, 2018
  6. Jeremy LintonJun 13, 2018
  7. Junio C HamanoJun 13, 2018

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.