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

[PATCH 2/2] unpack-objects: allocate NUL byte at the buffer end

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Mar 1, 2008, 21:21 UTC
Message-ID
<12044064831419-git-send-email-mkoegler@auto.tuwien.ac.at>
In-Reply-To
<12044064822655-git-send-email-mkoegler@auto.tuwien.ac.at>
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
 builtin-unpack-objects.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 9d2a854..1845abc 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -86,7 +86,8 @@ static void use(int bytes)
 static void *get_data(unsigned long size)
 {
 	z_stream stream;
-	void *buf = xmalloc(size);
+	char *buf = xmalloc(size + 1);
+	buf[size] = 0;
 
 	memset(&stream, 0, sizeof(stream));
 
-- 
1.5.4.2.g4b5fd.dirty
Previous: Martin KoeglerNext: Junio C Hamano
Message 2 of 3 in “index-pack: allocate NUL byte at the buffer end”
  1. 1/2 index-pack: allocate NUL byte at the buffer endMartin Koegler, Mar 1, 2008
  2. 2/2 unpack-objects: allocate NUL byte at the buffer endMartin Koegler, Mar 1, 2008
  3. Junio C HamanoMar 2, 2008

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.