package/source/zipapi/ZipFile.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 0f39e6fbb48dae29778c305ddd576d698a8251ad
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Nov 7 13:50:01 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Nov 7 15:47:43 2024 +0100

    tdf#162944 package: try to detect Zip64 via version
    
    https://rzymek.github.io/post/excel-zip64/ claims that it's sufficient
    for the version number to be 45 (4.5 - File uses ZIP64 format
    extensions) for Excel to read a zip entry's data descriptor as
    Zip64, while the Zip APPNOTE seems to require a zip64 extended
    information extra field to be present (see 4.3.9.2).
    
    Let's try to use the "version needed to extract" to be able to read
    zip files produced by Apache POI Zip64Mode.Always.
    
    Change-Id: I20f10471e3a85eb42d21c0cb08e36e345ef8fc9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176211
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/package/source/zipapi/ZipFile.cxx 
b/package/source/zipapi/ZipFile.cxx
index 39a9cc4fca50..d270b8d35463 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -964,7 +964,8 @@ sal_uInt64 ZipFile::readLOC_Impl(ZipEntry &rEntry, 
std::vector<sal_Int8>& rNameB
     // Just verify the path and calculate the data offset and otherwise
     // rely on the central directory info.
 
-    headerMemGrabber.ReadInt16(); // version - ignore any mismatch (Maven 
created JARs)
+    // version - ignore any mismatch (Maven created JARs)
+    sal_uInt16 const nVersion = headerMemGrabber.ReadUInt16();
     sal_uInt16 const nLocFlag = headerMemGrabber.ReadUInt16(); // general 
purpose bit flag
     sal_uInt16 const nLocMethod = headerMemGrabber.ReadUInt16(); // 
compression method
     // Do *not* compare timestamps, since MSO 2010 can produce documents
@@ -1021,6 +1022,11 @@ sal_uInt64 ZipFile::readLOC_Impl(ZipEntry &rEntry, 
std::vector<sal_Int8>& rNameB
             isZip64 = readExtraFields(extraMemGrabber, nExtraLen,
                     nLocSize, nLocCompressedSize, oOffset64, &aNameView);
         }
+        if (!isZip64 && 45 <= nVersion)
+        {
+            // for Excel compatibility, assume Zip64 - 
https://rzymek.github.io/post/excel-zip64/
+            isZip64 = true;
+        }
 
         // Just plain ignore bits 1 & 2 of the flag field - they are either
         // purely informative, or even fully undefined (depending on method).

Reply via email to