diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-02-10 13:02:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-02-10 13:02:16 -0800 |
commit | c329898abb167f05e37f3d0305e833127a26a4d0 (patch) | |
tree | a1011f24c17d6eec6edb52702f5803db5eee5d6f /sha1_file.c | |
parent | Merge branch 'jh/maint-config-file-prefix' into maint (diff) | |
parent | Fix integer overflow in unpack_compressed_entry() (diff) | |
download | tgif-c329898abb167f05e37f3d0305e833127a26a4d0.tar.xz |
Merge branch 'il/maint-xmallocz' into maint
* il/maint-xmallocz:
Fix integer overflow in unpack_compressed_entry()
Fix integer overflow in unpack_sha1_rest()
Fix integer overflow in patch_delta()
Add xmallocz()
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c index 63981fb3fd..23d347c45f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1232,7 +1232,7 @@ static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned lon static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size, const unsigned char *sha1) { int bytes = strlen(buffer) + 1; - unsigned char *buf = xmalloc(1+size); + unsigned char *buf = xmallocz(size); unsigned long n; int status = Z_OK; @@ -1260,7 +1260,6 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size while (status == Z_OK) status = git_inflate(stream, Z_FINISH); } - buf[size] = 0; if (status == Z_STREAM_END && !stream->avail_in) { git_inflate_end(stream); return buf; @@ -1583,8 +1582,7 @@ static void *unpack_compressed_entry(struct packed_git *p, z_stream stream; unsigned char *buffer, *in; - buffer = xmalloc(size + 1); - buffer[size] = 0; + buffer = xmallocz(size); memset(&stream, 0, sizeof(stream)); stream.next_out = buffer; stream.avail_out = size + 1; |