package/qa/cppunit/data/pass/no_usb_2024-11-06.xlsx |binary package/qa/cppunit/data/tdf163818.odg |binary package/qa/cppunit/test_zippackage.cxx | 22 +++++++++++++ package/source/zipapi/ZipFile.cxx | 33 +++++++++++++------- sfx2/source/view/viewfrm.cxx | 5 +-- 5 files changed, 47 insertions(+), 13 deletions(-)
New commits: commit 1ac6603b3ff93ba32362b4805bcd3cd26db809f4 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Nov 8 18:08:58 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Nov 11 14:58:26 2024 +0100 tdf#163818 package: fix recovery of zip entry local header with ... ... compressed size = 0. The problem is that vector::data() on a vector of size 0 returns nullptr, and osl_readFile into a nullptr buffer returns E_INVAL, which causes an exception to be thrown. Catch the exception, so that there is a chance to read the values from the data descriptor instead. (regression from commit 32cad89592ec04ab552399095c91dd76afb3002c and/or commit a6ad198d097fb4a503c8d5831d484ff46721134b) Change-Id: I9b2d9a930997146faf224d8033955b142fe93f58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176289 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit 80cda6954adc88eac3b99171acafea004976915b) diff --git a/package/qa/cppunit/data/tdf163818.odg b/package/qa/cppunit/data/tdf163818.odg new file mode 100644 index 000000000000..a01424acc27d Binary files /dev/null and b/package/qa/cppunit/data/tdf163818.odg differ diff --git a/package/qa/cppunit/test_zippackage.cxx b/package/qa/cppunit/test_zippackage.cxx index e8f3f910bb5a..354429576032 100644 --- a/package/qa/cppunit/test_zippackage.cxx +++ b/package/qa/cppunit/test_zippackage.cxx @@ -425,6 +425,28 @@ CPPUNIT_TEST_FIXTURE(ZipPackageTest, testTdf163341) m_xContext); } +CPPUNIT_TEST_FIXTURE(ZipPackageTest, testTdf163818) +{ + auto const url(m_directories.getURLFromSrc(u"/package/qa/cppunit/data/tdf163818.odg")); + uno::Sequence<uno::Any> const args{ + uno::Any(url), + uno::Any(beans::NamedValue("StorageFormat", uno::Any(embed::StorageFormats::PACKAGE))) + }; + + // unclear if this should be allowed? + CPPUNIT_ASSERT_THROW(m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + ZipPackage, args, m_xContext), + css::packages::zip::ZipIOException); + + // recovery should work + uno::Sequence<uno::Any> const args2{ + uno::Any(url), uno::Any(beans::NamedValue(u"RepairPackage"_ustr, uno::Any(true))), + uno::Any(beans::NamedValue("StorageFormat", uno::Any(embed::StorageFormats::ZIP))) + }; + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(ZipPackage, args2, + m_xContext); +} + //CPPUNIT_TEST_SUITE_REGISTRATION(...); //CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 1723b8c1de30..778af131c624 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -1838,20 +1838,27 @@ bool ZipFile::checkSizeAndCRC( const ZipEntry& aEntry ) { ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() ); - sal_Int32 nCRC = 0; - sal_Int64 nSize = 0; + try + { + sal_Int32 nCRC = 0; + sal_Int64 nSize = 0; - if( aEntry.nMethod == STORED ) - return ( getCRC( aEntry.nOffset, aEntry.nSize ) == aEntry.nCrc ); + if( aEntry.nMethod == STORED ) + return ( getCRC( aEntry.nOffset, aEntry.nSize ) == aEntry.nCrc ); - if (aEntry.nCompressedSize < 0) + if (aEntry.nCompressedSize < 0) + { + SAL_WARN("package", "bogus compressed size of: " << aEntry.nCompressedSize); + return false; + } + + getSizeAndCRC( aEntry.nOffset, aEntry.nCompressedSize, &nSize, &nCRC ); + return ( aEntry.nSize == nSize && aEntry.nCrc == nCRC ); + } + catch (uno::Exception const&) { - SAL_WARN("package", "bogus compressed size of: " << aEntry.nCompressedSize); return false; } - - getSizeAndCRC( aEntry.nOffset, aEntry.nCompressedSize, &nSize, &nCRC ); - return ( aEntry.nSize == nSize && aEntry.nCrc == nCRC ); } sal_Int32 ZipFile::getCRC( sal_Int64 nOffset, sal_Int64 nSize ) commit 01e65e6458e9b258461bbd31f38699384208684b Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Nov 7 13:50:01 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Nov 11 14:58:25 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> (cherry picked from commit cc530b1789eff756eaaded4f21595af1a169b0ce) 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 5b5502cb5ea1..1723b8c1de30 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). commit 28595547a63edf217629fca6cc769d1960adb24e Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Nov 11 14:28:13 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Nov 11 14:58:25 2024 +0100 sfx2: -Werror=unused-but-set-variable bIsInfobarShown And -Werror=unused-function Change-Id: Ie4070fe05372da16210aa41f45d0388ea68079e2 diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 9528d1439263..9b333d7ea030 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -52,7 +52,7 @@ #include <vcl/weld.hxx> #include <vcl/weldutils.hxx> #if !ENABLE_WASM_STRIP_PINGUSER -#include <unotools/VersionConfig.hxx> +//#include <unotools/VersionConfig.hxx> #endif #include <unotools/securityoptions.hxx> #include <svtools/miscopt.hxx> @@ -1623,9 +1623,8 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface()); GetDispatcher()->ExecuteList(SID_TIPOFTHEDAY, SfxCallMode::SLOT, {}, { &aDocFrame }); } -#else - (void) bIsInfobarShown; #endif + (void) bIsInfobarShown; break; }