package/qa/cppunit/data/pass/no_usb_2024-11-06.xlsx |binary
 package/source/zipapi/ZipFile.cxx                   |    8 +++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit cc530b1789eff756eaaded4f21595af1a169b0ce
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Nov 7 13:50:01 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Nov 11 09:24:22 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
    (cherry picked from commit 0f39e6fbb48dae29778c305ddd576d698a8251ad)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176220
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/package/qa/cppunit/data/pass/no_usb_2024-11-06.xlsx 
b/package/qa/cppunit/data/pass/no_usb_2024-11-06.xlsx
new file mode 100644
index 000000000000..edba1807717e
Binary files /dev/null and 
b/package/qa/cppunit/data/pass/no_usb_2024-11-06.xlsx differ
diff --git a/package/source/zipapi/ZipFile.cxx 
b/package/source/zipapi/ZipFile.cxx
index e685aa85b2a9..86b78a4a30f0 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -932,7 +932,8 @@ sal_uInt64 ZipFile::readLOC(ZipEntry &rEntry)
     // Just verify the path and calculate the data offset and otherwise
     // rely on the central directory info.
 
-    aGrabber.ReadInt16(); // version - ignore any mismatch (Maven created JARs)
+    // version - ignore any mismatch (Maven created JARs)
+    sal_uInt16 const nVersion = aGrabber.ReadUInt16();
     sal_uInt16 const nLocFlag = aGrabber.ReadUInt16(); // general purpose bit 
flag
     sal_uInt16 const nLocMethod = aGrabber.ReadUInt16(); // compression method
     // Do *not* compare timestamps, since MSO 2010 can produce documents
@@ -992,6 +993,11 @@ sal_uInt64 ZipFile::readLOC(ZipEntry &rEntry)
             isZip64 = readExtraFields(extraMemGrabber, nExtraLen,
                     nLocSize, nLocCompressedSize, oOffset64, &sLOCPath);
         }
+        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