Skip to content

Add more ZipArchive tests to confirm the Zip64 fix does not affect reading zip files generatd with the old bug #103152

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

Closed
wants to merge 2 commits into from

Conversation

carlossanlop
Copy link
Member

We recently fixed a bug in ZipArchive that prevented setting the zip64 bit corectly in the local header for very large files: #102053

This PR adds two more tests to confirm the above test works:

  • One OuterLoop test for .NET that creates a large zip file, manually sets the zip64 bit to the old value, then attempts to open the zip again with ZipArchive, to confirm it is indeed read without problems by ZipArchive after the fix.
  • A manual test split in two parts:
    • A .NET test that simply generates a large zip file with the zip64 fix.
    • A .NET Framework test that expects that large zip file in the TEMP folder, then confirms ZipArchive can read it without problems.

…y value, then confirms it can still be opened using the fixed ZipArchive code.
…ge zip archive with the zip64 fix, and another one that is run using .NET Framework which reads the buggy zip file and confirms it can be read without problems.
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.

using FileStream fs = File.OpenRead(zipArchivePath);

// Open archive to verify that we can still read an archive with the buggy version
using (ZipArchive zip = new ZipArchive(fs, ZipArchiveMode.Read))
Copy link
Member

@ericstj ericstj Jun 7, 2024

Choose a reason for hiding this comment

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

The bug in NETFX was actually with the validation in System.IO.Packaging. So this would pass even with the broken zip.

I'm not sure there's value in having this test committed even if we made it for IO.Packaging, since it has manual steps.

Maybe there's some value in having some suite of compatibility tests that produce different zips / IO.Packaging packages on one framework, and then consume them on the other framework without intervention? Perhaps those could be done in a way that they are a theory based on a number of different scenarios? I don't see that as a necessary thing for this particular fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have prior art running two different test processes for different frameworks?

Copy link
Member

@ericstj ericstj Dec 17, 2024

Choose a reason for hiding this comment

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

Not different processes, but we do have compatibility tests, where we check in data for use in testing. We also have other tests that can ensure checked-in data matches that which is currently generated. Doing so can make sure we keep the checked in data up to date on one framework and test with it on a different framework. Maybe that's infeasible here since these files are gigantic?


fs.Position = 0;

// Open archive to modify the bit as it used to look before fix
Copy link
Member

Choose a reason for hiding this comment

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

I noticed the source has a define for DEBUG_FORCE_ZIP64. I don't see us ever use that, but I imagine the idea was we could use reflection to set that field and it would make a smaller zip use Zip64. That might be an interesting method to test this without forcing things to outerloop.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good to keep it in mind. I wasn't aware that it could be used for testing. At the moment I felt that it was more important to confirm that the real life scenario is working. I'll consider using the define in the future.

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 3 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • src/libraries/System.IO.Compression/tests/Manual/System.IO.Compression.Manual.Net.Tests.csproj: Language not supported
  • src/libraries/System.IO.Compression/tests/Manual/System.IO.Compression.Manual.NetFramework.Tests.csproj: Language not supported
Comments suppressed due to low confidence (1)

src/libraries/System.IO.Compression/tests/ZipArchive/zip_LargeFiles.cs:144

  • [nitpick] Consider renaming 'buggyZip64Version' to 'legacyZip64Version' for better clarity.
ushort buggyZip64Version = 20;

@ericstj
Copy link
Member

ericstj commented Dec 17, 2024

@carlossanlop I'm not sure what you wanted to do with this PR. One piece of blocking feedback I had was that the manual regression test added here wouldn't have reproduced the bug on NetFx since it was testing the IO.Compression implementation of Zip and not the WPF implementation in IO.Packaging.

@carlossanlop
Copy link
Member Author

Closing based on feedback.

@carlossanlop carlossanlop deleted the ExtraZip64Test branch January 15, 2025 18:28
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2025
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