提交 3aee68aa 编写于 作者: I Ilari Liusvaara 提交者: Junio C Hamano

Fix integer overflow in unpack_sha1_rest()

[jc: later NUL termination by the caller becomes unnecessary]
Signed-off-by: NIlari Liusvaara <ilari.liusvaara@elisanet.fi>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 222083a1
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册