From dc589e5b78f0cc7fce4d6917bb80f002c31bd288 Mon Sep 17 00:00:00 2001 From: Gan Keyu Date: Sun, 19 Nov 2023 14:04:34 +0800 Subject: [PATCH] Check LH offset when writing LH. Fix #94899 ZipArchiveEntry didn't set ZIP64 in local headers for small files if their offset are >4GB. --- .../src/System/IO/Compression/ZipArchiveEntry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs index 14988fcab72817..00a51d081bdad7 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs @@ -964,7 +964,7 @@ private void WriteCrcAndSizesInLocalHeader(bool zip64HeaderUsed) long finalPosition = _archive.ArchiveStream.Position; BinaryWriter writer = new BinaryWriter(_archive.ArchiveStream); - bool zip64Needed = SizesTooLarge() + bool zip64Needed = SizesTooLarge() || (_offsetOfLocalHeader > uint.MaxValue) #if DEBUG_FORCE_ZIP64 || _archive._forceZip64 #endif