Fix DataErrorException when extracting LZMA-compressed zero-byte ZIP entries#1238
Merged
adamhathcock merged 3 commits intoreleasefrom Mar 1, 2026
Merged
Fix DataErrorException when extracting LZMA-compressed zero-byte ZIP entries#1238adamhathcock merged 3 commits intoreleasefrom
adamhathcock merged 3 commits intoreleasefrom
Conversation
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com> # Conflicts: # src/SharpCompress/Common/Zip/ZipFilePart.Async.cs # src/SharpCompress/Common/Zip/ZipFilePart.cs
Contributor
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
Files Reviewed (6 files)
Note: The tests added ( |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes extraction of ZIP archives containing LZMA-compressed entries whose uncompressed size is explicitly zero (preventing DataErrorException), and adds regression tests for both seekable-archive and streaming-reader scenarios.
Changes:
- Short-circuit LZMA decompression for known-zero uncompressed size entries (sync + async) and drain remaining compressed bytes.
- Add new regression tests and a minimal test archive containing an empty LZMA entry.
- Update
packages.lock.jsondependency resolutions forMicrosoft.NET.ILLink.Tasks.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/SharpCompress/Common/Zip/ZipFilePart.cs |
Adds LZMA early-return path for zero-size entries. |
src/SharpCompress/Common/Zip/ZipFilePart.Async.cs |
Adds async equivalent early-return path for zero-size entries. |
tests/TestArchives/Archives/Zip.lzma.empty.zip |
Adds a fixture ZIP containing an empty LZMA-compressed entry. |
tests/SharpCompress.Test/Zip/ZipArchiveTests.cs |
Adds seekable-archive regression test for extracting empty LZMA entry. |
tests/SharpCompress.Test/Zip/ZipReaderTests.cs |
Adds streaming-reader regression test for extracting empty LZMA entry. |
src/SharpCompress/packages.lock.json |
Adjusts locked versions for Microsoft.NET.ILLink.Tasks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Mar 2, 2026
This was referenced Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
release version of #1237
fixes #1236
This pull request improves how the library handles ZIP archives containing LZMA-compressed entries with a known uncompressed size of zero. It ensures that such entries are correctly extracted as empty streams, both in regular and streaming scenarios. Additionally, it updates test coverage for these cases and adjusts some package dependencies.
LZMA zero-size entry handling:
ZipFilePart.cs) and asynchronous (ZipFilePart.Async.cs) decompression logic to immediately return an empty stream and skip remaining compressed bytes when the uncompressed size is explicitly zero and the EOS marker flag is not set. This prevents unnecessary processing and fixes extraction for these edge cases. [1] [2]Testing improvements:
Zip_LZMA_ZeroSizeEntry_CanExtract) to ensure that extracting a zero-size LZMA entry from a ZIP archive produces an empty output stream.Zip_LZMA_ZeroSizeEntry_CanExtract_Streaming) to verify that zero-size LZMA entries are handled correctly during streaming extraction.Dependency updates:
Microsoft.NET.ILLink.Taskspackage versions inpackages.lock.jsonfor bothnet10.0andnet8.0target frameworks to ensure compatibility. [1] [2]