Skip to content

Commit 47a876a

Browse files
committed
Merge branch 'jc/maint-fix-unpack-zlib-check' into maint
* jc/maint-fix-unpack-zlib-check: Fix incorrect error check while reading deflated pack data
2 parents 071b489 + 39eea7b commit 47a876a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sha1_file.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,6 @@ unsigned long get_size_from_delta(struct packed_git *p,
13571357
in = use_pack(p, w_curs, curpos, &stream.avail_in);
13581358
stream.next_in = in;
13591359
st = git_inflate(&stream, Z_FINISH);
1360-
if (st == Z_BUF_ERROR && (stream.avail_in || !stream.avail_out))
1361-
break;
13621360
curpos += stream.next_in - in;
13631361
} while ((st == Z_OK || st == Z_BUF_ERROR) &&
13641362
stream.total_out < sizeof(delta_head));
@@ -1589,15 +1587,15 @@ static void *unpack_compressed_entry(struct packed_git *p,
15891587
buffer[size] = 0;
15901588
memset(&stream, 0, sizeof(stream));
15911589
stream.next_out = buffer;
1592-
stream.avail_out = size;
1590+
stream.avail_out = size + 1;
15931591

15941592
git_inflate_init(&stream);
15951593
do {
15961594
in = use_pack(p, w_curs, curpos, &stream.avail_in);
15971595
stream.next_in = in;
15981596
st = git_inflate(&stream, Z_FINISH);
1599-
if (st == Z_BUF_ERROR && (stream.avail_in || !stream.avail_out))
1600-
break;
1597+
if (!stream.avail_out)
1598+
break; /* the payload is larger than it should be */
16011599
curpos += stream.next_in - in;
16021600
} while (st == Z_OK || st == Z_BUF_ERROR);
16031601
git_inflate_end(&stream);

0 commit comments

Comments
 (0)