mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-11 05:24:56 +00:00
[PR #1023] [MERGED] Fix version mismatch between Local File Header and Central Directory File Header in Zip archives #1443
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?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1023
Author: @Copilot
Created: 11/19/2025
Status: ✅ Merged
Merged: 11/25/2025
Merged by: @adamhathcock
Base:
master← Head:copilot/fix-zip64-validation-issue📝 Commits (9)
51237a3Initial plan434ce05Fix Zip64 version mismatch between LFH and CDFH0fe48c6Enhance fix to handle LZMA/PPMd/BZip2/ZStandard compression methods8b0a1c6Update tests/SharpCompress.Test/Zip/Zip64VersionConsistencyTests.cscc10a12Update tests/SharpCompress.Test/Zip/Zip64VersionConsistencyTests.cs04c044cUpdate tests/SharpCompress.Test/Zip/Zip64VersionConsistencyTests.cs81ca15bUpdate src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.csd41908afixes for claritya92aaa5Remove ZipCompressionMethod.None from version 63 check📊 Changes
3 files changed (+466 additions, -2 deletions)
View changed files
📝
src/SharpCompress/Archives/IArchiveEntryExtensions.cs(+2 -1)📝
src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.cs(+23 -1)➕
tests/SharpCompress.Test/Zip/Zip64VersionConsistencyTests.cs(+441 -0)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.