镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix Zip64 data descriptors on non-seekable streams - #136963

Merged
rzikm merged 1 commit into
dotnet:mainfrom
akasakariko:fix/zip64-nonseekable-descriptor
Nov 12, 2026
Merged

rzikm merged 1 commit into
dotnet:mainfrom
akasakariko:fix/zip64-nonseekable-descriptor

Conversation

@akasakariko

Copy link
Copy Markdown
Contributor

Writing an entry larger than 4 GiB to a non-seekable stream currently emits a ZIP32 local header followed by a Zip64 data descriptor, so readers using local headers cannot determine the descriptor width

Declare Zip64 before writing streamed entry data and always use 64-bit descriptor sizes for those entries, including small entries
Preserve the original local Zip64 declaration when Update mode rewrites metadata while retaining the existing descriptor
Extend the existing creation and metadata-update tests for both synchronous and asynchronous paths

Compatibility: streamed entries with data now require a Zip64-capable reader and small streamed entries gain 28 bytes of metadata
Applications requiring ZIP32 compatibility for small entries can write to a seekable stream
No public API changes

Local validation on macOS arm64:

  • Four focused regression cases failed before the fix and passed afterward
  • Actual 4 GiB + 1 MiB reproduction passed with the locally built runtime, including unzip -t and reading the following entry through piped tar input
  • System.IO.Compression: 3026 regular tests and 92 OuterLoop tests passed
  • System.IO.Compression.ZipFile: 379 regular tests and 16 OuterLoop tests passed
  • Browser System.IO.Compression: 1283 tests passed, including all four regression cases
  • Native and browser library builds passed, as did git diff --check
  • Whitespace verification reports only the same two pre-existing diagnostics at zip_CreateTests.cs:82 as the unchanged baseline

Browser builds used /p:EnableHotReloadInRuntimeConfigDevFile=false for the SDK issue tracked in dotnet/sdk#56656, with no SDK or build-system changes in this PR
The browser host logs Aborted(Assertion failed) during teardown after WASM EXIT 0 in both the unmodified-product control and passing patched run, while XHarness and the build return 0

Resolves #127389

Note

This PR was prepared with AI assistance

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 4, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@akasakariko

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@alinpahontu2912

Copy link
Copy Markdown
Member

Looks good to me, thanks for the contribution! Do you have anything to add @rzikm @iremyux ?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Requiring ZIP64 for all non-empty entries on non-seekable streams, even small entries, needs maintainer confirmation of downstream-reader compatibility trade-offs and breaking-change handling.

No open issues 🎉

What changed in this PR

Fixes ZIP header and data-descriptor consistency in System.IO.Compression for non-seekable output, allowing readers to determine descriptor width before reading entry data.

Changes:

  • Declares Zip64 before writing streamed entry data and uses 64-bit descriptor sizes, including for small entries.
  • Preserves local Zip64 declarations during metadata-only updates that retain existing descriptors.
  • Extends synchronous and asynchronous regression tests for creation and metadata updates.

Streamed entries containing data now require a Zip64-capable reader; small entries gain 28 bytes of metadata. No public API changes are introduced.

File Description
src/​libraries/​System.IO.Compression/​tests/​ZipArchive/​zip_UpdateTests.cs Verifies retained Zip64 headers and descriptors after metadata updates.
src/​libraries/​System.IO.Compression/​tests/​ZipArchive/​zip_CreateTests.cs Checks streamed Zip64 structure and exercises asynchronous entry writes.
src/​libraries/​System.IO.Compression/​src/​System/​IO/​Compression/​ZipBlocks.cs Reports whether parsed local extra fields contain a Zip64 declaration.
src/​libraries/​System.IO.Compression/​src/​System/​IO/​Compression/​ZipBlocks.Async.cs Returns the same Zip64 declaration information during asynchronous parsing.
src/​libraries/​System.IO.Compression/​src/​System/​IO/​Compression/​ZipArchiveEntry.cs Declares streamed Zip64 entries, selects descriptor width, and preserves retained declarations.
src/​libraries/​System.IO.Compression/​src/​System/​IO/​Compression/​ZipArchiveEntry.Async.cs Records local Zip64 declarations during asynchronous loading.

Review effort: Balanced

@rzikm
rzikm requested a review from iremyux November 6, 2026 08:07

@iremyux iremyux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rzikm
rzikm merged commit 61b01e5 into dotnet:main Nov 12, 2026
95 of 97 checks passed
@rzikm rzikm added the breaking-change Issue or PR that represents a breaking API or functional change over a previous release. label Nov 12, 2026
@dotnet-policy-service dotnet-policy-service Bot added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Nov 12, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET Breaking Change Notification DL.

Tagging @dotnet/compat for awareness of the breaking change.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 83914fd9 Deployed Nov 12, 2026 by dotnet-policy-service[bot] via pat_pool #12328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.IO.Compression breaking-change Issue or PR that represents a breaking API or functional change over a previous release. community-contribution Indicates that the PR has been added by a community member needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zip64 Data Descriptor Bug on Non-Seekable Streams

5 participants