summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-11-07 13:50:01 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2024-11-07 15:47:43 +0100
commit0f39e6fbb48dae29778c305ddd576d698a8251ad (patch)
treec43877c812075328d823761be9363ce4080e1ab7 /package
parent138ff29f7e7cb504f2c8d6b30df56494687d443f (diff)
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.stahl@allotropia.de> Tested-by: Jenkins
Diffstat (limited to 'package')
-rw-r--r--package/source/zipapi/ZipFile.cxx8
1 files changed, 7 insertions, 1 deletions
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).