Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlari Liusvaara <ilari.liusvaara@elisanet.fi>2010-01-26 21:24:14 +0300
committerJunio C Hamano <gitster@pobox.com>2010-01-27 00:00:10 +0300
commit3aee68aa68e80856de26340b707148d8f8d5b82e (patch)
tree34ccbcc121881c3846d35cf5fa5135243c87ae6e /sha1_file.c
parent222083a1585c058fd2bbcb76db1ea824ee3df17f (diff)
Fix integer overflow in unpack_sha1_rest()
[jc: later NUL termination by the caller becomes unnecessary] Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 63981fb3fd..a903247677 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;