summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2011-06-20 17:34:01 +0200
committerCarlos Martín Nieto <cmn@elego.de>2011-06-20 17:34:01 +0200
commitcdb6f9bf5e77b6e83d4bdc6cd75c31d0d3377800 (patch)
treecec1bd4d0f63565ba0ff5b5d2d9e1e644e5d3746 /src
parent37172582ec7ff9cb47c43c5d5b2334bf8c547569 (diff)
downloadlibgit2-cdb6f9bf5e77b6e83d4bdc6cd75c31d0d3377800.tar.gz
Allocate enough memory for the terminator in commit parsing
Also allow space for the null-terminator when allocating the buffer in packfile_unpack_compressed. Up to now, the last newline had served as a terminator, but 858ef372 searches for a double-newline and exposes the problem. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'src')
-rw-r--r--src/odb_pack.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 8a88a0baa..2328f527c 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -1246,7 +1246,8 @@ static int packfile_unpack_compressed(
z_stream stream;
unsigned char *buffer, *in;
- buffer = git__malloc(size);
+ buffer = git__malloc(size + 1);
+ memset(buffer, 0x0, size + 1);
memset(&stream, 0, sizeof(stream));
stream.next_out = buffer;