mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-08 13:34:57 +00:00
[PR #1023] Fix version mismatch between Local File Header and Central Directory File Header in Zip archives #1446
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?
Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1023
State: closed
Merged: Yes
Plan: Fix Zip64 Version Mismatch Between LFH and CDFH
Problem
When
UseZip64=truebut files are small (< 4GB), there's a version mismatch:Root Cause
ZipWriter.WriteHeader(): Version is set based on compression method and Zip64 usageZipCentralDirectoryEntry.Write(): Version was set to 45 only when actual sizes/offsets exceed uint.MaxValue, ignoring compression method requirementsSolution
ZipCentralDirectoryEntry.Write()to properly handle:ZipCompressionMethod.Nonefrom version 63 check (per review feedback)Changes Made
Modified
ZipCentralDirectoryEntry.cs:Added
Zip64VersionConsistencyTests.cs: Created 5 testsTest Results
This ensures archives created with
UseZip64=trueor advanced compression methods can be opened by System.IO.Packaging and other strict ZIP readers.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.