From: Linus Torvalds Date: Sun, 11 Sep 2005 17:54:45 GMT Subject: Re: [PATCH] Fix buffer overflow in ce_flush(). Message-ID: 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 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 --- 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)