Skip to content

Commit

Permalink
Fix infinite loop on bad literal data
Browse files Browse the repository at this point in the history
Returning true here just puts us in an infinite loop, not sure what was supposed to happen?

Fixes icsharpcode#229.
  • Loading branch information
piksel authored Jun 16, 2018
1 parent 4ad264b commit 2dcb656
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ICSharpCode.SharpZipLib/Zip/Compression/Inflater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ private bool DecodeHuffman()
while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) {
outputWindow.Write(symbol);
if (--free < 258) {
return true;
// If this happens we will be stuck in an infinite loop.
throw new SharpZipBaseException("Literal symbol count exceeds window size, input file may be corrupt.");
}
}

Expand Down

0 comments on commit 2dcb656

Please sign in to comment.