Repository navigation
Improve ZipArchive diagnostics for empty and invalid streams - #137247
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the ZIP stream-validation and diagnostic changes.
No open issues 🎉
What changed in this PR
Improves ZipArchive diagnostics for empty and invalid input streams, addressing the confusing error messages described in #136215.
Changes:
- Adds shared stream-length validation to synchronous and asynchronous ZIP readers.
- Introduces a dedicated empty-stream message and clarifies the missing End of Central Directory message.
- Adds regression tests for invalid inputs, empty archive creation, and prefixed archives.
| File | Description |
|---|---|
src/libraries/System.IO.Compression/tests/ZipArchive/zip_InvalidParametersAndStrangeFiles.cs |
Tests diagnostics and valid archive scenarios across synchronous and asynchronous paths. |
src/libraries/System.IO.Compression/tests/System.IO.Compression.Tests.csproj |
Makes library string resources available to test assertions. |
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs |
Validates stream length before locating the End of Central Directory. |
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.Async.cs |
Applies the same validation to asynchronous reading. |
src/libraries/System.IO.Compression/src/Resources/Strings.resx |
Adds and clarifies diagnostic messages. |
Review effort: Balanced
3 tasks
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.
Report distinct errors for empty streams and missing End of Central Directory records in synchronous and asynchronous ZIP readers.
Fixes #136215