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 committed Jul 15, 2018
1 parent fb4ed40 commit 2f16eff
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 2f16eff

Please sign in to comment.