diff options
author | Duy Nguyen <pclouds@gmail.com> | 2014-12-08 15:17:55 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-12-09 11:56:37 -0800 |
commit | a1e920a0a7747f0820e62b22b67fd36fb1d74607 (patch) | |
tree | ce4725cc0d17d78462335824a7719052034654ec /builtin/index-pack.c | |
parent | 7add441984063d2c34fa8de252b8ceb803e7981a (diff) | |
download | git-a1e920a0a7747f0820e62b22b67fd36fb1d74607.tar.gz |
index-pack: terminate object buffers with NULjs/fsck-tag-validation
We have some tricky checks in fsck that rely on a side effect of
require_end_of_header(), and would otherwise easily run outside
non-NUL-terminated buffers. This is a bit brittle, so let's make sure
that only NUL-terminated buffers are passed around to begin with.
Jeff "Peff" King contributed the detailed analysis which call paths are
involved and pointed out that we also have to patch the get_data()
function in unpack-objects.c, which is what Johannes "Dscho" Schindelin
implemented.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Analyzed-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/index-pack.c')
-rw-r--r-- | builtin/index-pack.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index f2465ff18e..f79b04e2c4 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -438,7 +438,7 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size, if (type == OBJ_BLOB && size > big_file_threshold) buf = fixed_buf; else - buf = xmalloc(size); + buf = xmallocz(size); memset(&stream, 0, sizeof(stream)); git_inflate_init(&stream); @@ -543,7 +543,7 @@ static void *unpack_data(struct object_entry *obj, git_zstream stream; int status; - data = xmalloc(consume ? 64*1024 : obj->size); + data = xmallocz(consume ? 64*1024 : obj->size); inbuf = xmalloc((len < 64*1024) ? len : 64*1024); memset(&stream, 0, sizeof(stream)); |