Skip to content

Revert "version needed to extract" fix #112922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

carlossanlop
Copy link
Member

@carlossanlop carlossanlop commented Feb 25, 2025

Reverts #112032

This reverts commit 68a88d1.

The dotnet/android team uses a tool called aapt2 to create zip files. The entries added by this tool set a “version needed to extract” metadata field with a value of 0.0. But sometimes this tool uses deflate compression, which requires a version of 2.0, which they don’t set correctly (full discussion in original issue).

When these zip files are then opened using our ZipArchive in Update mode and new entries are added to the archive, the central directory is correctly updated with the correct version, but the local file header for existing entries isn’t rewritten by us, leading to a mismatch.

We tried to fix this by forcing the local file header to be rewritten when the “version needed to extract” changes, ensuring consistency between the local file header and the central directory header. Unfortunately, this attempt to increase correctness made matters worse, as tools like 7zip now report that the zip files are corrupt.

So this PR reverts this change to avoid breaking other tools when they open zip files with this issue that are then modified by our ZipArchive.

The dotnet/android team has a workaround: instead of using aapt2 they can use a tool called android-libzipsharp, which has the drawback of being less performant, but it works fine.

@edwardneal @jonathanpeppers @ericstj

…ntral and local directories when updating entries.

This reverts commit 68a88d1.
@Copilot Copilot AI review requested due to automatic review settings February 25, 2025 20:03
@carlossanlop carlossanlop self-assigned this Feb 25, 2025
@carlossanlop carlossanlop requested review from ViktorHofer, ericstj, artl93 and a team February 25, 2025 20:04
Copy link
Contributor

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

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

src/libraries/System.IO.Compression/tests/ZipArchive/zip_InvalidParametersAndStrangeFiles.cs:907

  • [nitpick] Removal of the 'ZipArchive_InvalidVersionToExtract' test reduces coverage for verifying the consistency between local file headers and central directory headers; please consider adding alternative tests if this functionality remains supported.
        [Fact]

src/libraries/System.IO.Compression/tests/ZipArchive/zip_InvalidParametersAndStrangeFiles.cs:928

  • The comment uses 'UNcompressed' with unexpected capitalization; consider using 'uncompressed' for consistency.
            // UNcompressed size

src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs:1245

  • Reverting the update to the 'Changes' flag in VersionToExtractAtLeast may reintroduce inconsistencies between the local file header and central directory header; please verify that this reversion fully aligns with the intended behavior in Update mode.
                    Changes |= ZipArchive.ChangeState.FixedLengthMetadata;

@carlossanlop
Copy link
Member Author

/backport to release/10.0-preview2

Copy link
Contributor

Started backporting to release/10.0-preview2: https://github.com/dotnet/runtime/actions/runs/13529959006

@carlossanlop
Copy link
Member Author

/ba-g The nativeaot leg is stuck

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants