@@ -1357,8 +1357,6 @@ unsigned long get_size_from_delta(struct packed_git *p,
1357
1357
in = use_pack (p , w_curs , curpos , & stream .avail_in );
1358
1358
stream .next_in = in ;
1359
1359
st = git_inflate (& stream , Z_FINISH );
1360
- if (st == Z_BUF_ERROR && (stream .avail_in || !stream .avail_out ))
1361
- break ;
1362
1360
curpos += stream .next_in - in ;
1363
1361
} while ((st == Z_OK || st == Z_BUF_ERROR ) &&
1364
1362
stream .total_out < sizeof (delta_head ));
@@ -1589,15 +1587,15 @@ static void *unpack_compressed_entry(struct packed_git *p,
1589
1587
buffer [size ] = 0 ;
1590
1588
memset (& stream , 0 , sizeof (stream ));
1591
1589
stream .next_out = buffer ;
1592
- stream .avail_out = size ;
1590
+ stream .avail_out = size + 1 ;
1593
1591
1594
1592
git_inflate_init (& stream );
1595
1593
do {
1596
1594
in = use_pack (p , w_curs , curpos , & stream .avail_in );
1597
1595
stream .next_in = in ;
1598
1596
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 */
1601
1599
curpos += stream .next_in - in ;
1602
1600
} while (st == Z_OK || st == Z_BUF_ERROR );
1603
1601
git_inflate_end (& stream );
0 commit comments