mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Failed validation when using Zip64 with System.IO.Packaging #720
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @a-carvallo on GitHub (Nov 18, 2025).
Originally assigned to: @Copilot on GitHub.
Hi there, ran into this little problem when using SharpCompress.
A zip archive created with
UseZip64set totruewill fail to open usingZipPackage(fromSystem.IO.Packaging) with .NET Framework 4.8.The exception occurs in
ZipIOLocalFileBlock.Validate()here:VersionNeededToExtractvalue is45whilecentralDirFileHeader.VersionNeededToExtractis20.This mismatch seems to come from the fact that in SharpCompress the Local File Header will always have its version set to
45whenUseZip64istrue, but the version in the Central Directory File Header will be45only if size/offset is overuint.MaxValue(which makes sense).Not sure what's the best way to handle this, an easy one would probably be to set both versions to
45as soon as the flag istrue? (but this may not be optimal/trivial).In SharpCompress these parts seem to be in
ZipWriter.WriteToStream()/ZipWriter.WriteHeader()for the LFH and inZipCentralDirectoryEntry.Write()for the CDFH.Small code to reproduce the issue:
Kind of related to #164