LZMA EOS marker detection

This commit is contained in:
Lars Vahlenberg
2023-12-09 13:41:35 +01:00
parent 67be0cd9d7
commit 0320db6b4a
3 changed files with 14 additions and 2 deletions

View File

@@ -207,14 +207,23 @@ public class LzmaStream : Stream
if (_availableBytes == 0 && !_uncompressedChunk)
{
_rangeDecoder.ReleaseStream();
// Check range corruption scenario
if (
!_rangeDecoder.IsFinished
|| (_rangeDecoderLimit >= 0 && _rangeDecoder._total != _rangeDecoderLimit)
)
{
throw new DataErrorException();
// Stream might have End Of Stream marker
_outWindow.SetLimit(toProcess + 1);
if (!_decoder.Code(_dictionarySize, _outWindow, _rangeDecoder))
{
_rangeDecoder.ReleaseStream();
throw new DataErrorException();
}
}
_rangeDecoder.ReleaseStream();
_inputPosition += _rangeDecoder._total;
if (_outWindow.HasPending)
{

View File

@@ -135,6 +135,9 @@ public class SevenZipArchiveTests : ArchiveTests
)
);
[Fact]
public void SevenZipArchive_EOS_FileRead() => ArchiveFileRead("7Zip.eos.7z");
[Fact]
public void SevenZipArchive_Delta_FileRead() => ArchiveFileRead("7Zip.delta.7z");

Binary file not shown.