summaryrefslogtreecommitdiff
path: root/builtin/unpack-objects.c
diff options
context:
space:
mode:
authorDuy Nguyen <pclouds@gmail.com>2014-12-08 14:17:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-12-09 19:56:37 (GMT)
commita1e920a0a7747f0820e62b22b67fd36fb1d74607 (patch)
treece4725cc0d17d78462335824a7719052034654ec /builtin/unpack-objects.c
parent7add441984063d2c34fa8de252b8ceb803e7981a (diff)
downloadgit-a1e920a0a7747f0820e62b22b67fd36fb1d74607.zip
git-a1e920a0a7747f0820e62b22b67fd36fb1d74607.tar.gz
git-a1e920a0a7747f0820e62b22b67fd36fb1d74607.tar.bz2
index-pack: terminate object buffers with NUL
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/unpack-objects.c')
-rw-r--r--builtin/unpack-objects.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 855d94b..ac66672 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -91,7 +91,7 @@ static void use(int bytes)
static void *get_data(unsigned long size)
{
git_zstream stream;
- void *buf = xmalloc(size);
+ void *buf = xmallocz(size);
memset(&stream, 0, sizeof(stream));