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

Re: [PATCH] Fix buffer overflow in ce_flush().

From
Linus Torvalds <torvalds@osdl.org>
Date
Sep 11, 2005, 17:54 UTC
Message-ID
<Pine.LNX.4.58.0509111050040.3242@g5.osdl.org>
In-Reply-To
<20050911132747.GA26401@mayhq.zapto.org>
On Sun, 11 Sep 2005, Qingning Huo wrote:
>
> Fix buffer overflow in ce_flush().
Thanks, good find. However, I'd almost prefer the simpler patch below..
		Linus

--- Fix buffer overflow in ce_flush()

Qingning Huo <qhuo@mayhq.co.uk> noticed that we migth overflow the write buffer when writing the final SHA1 of the index file. Make sure we have enough extra room at the end that we can always add the final checksum to the end of the buffer.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/read-cache.c b/read-cache.c
--- a/read-cache.c
+++ b/read-cache.c
@@ -428,7 +428,7 @@ unmap:
 }
 
 #define WRITE_BUFFER_SIZE 8192
-static unsigned char write_buffer[WRITE_BUFFER_SIZE];
+static unsigned char write_buffer[WRITE_BUFFER_SIZE+20];
 static unsigned long write_buffer_len;
 
 static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “Fix buffer overflow in ce_flush().”
  1. Fix buffer overflow in ce_flush().Qingning Huo, Sep 11, 2005
  2. Junio C HamanoSep 11, 2005
  3. Linus TorvaldsSep 11, 2005
  4. Junio C HamanoSep 11, 2005
  5. Linus TorvaldsSep 11, 2005

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.