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 commit32cad89592
and/or commita6ad198d09
) Change-Id: I9b2d9a930997146faf224d8033955b142fe93f58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176289 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
This commit is contained in:
parent
950cd20f5f
commit
80cda6954a
3 changed files with 40 additions and 11 deletions
BIN
package/qa/cppunit/data/tdf163818.odg
Normal file
BIN
package/qa/cppunit/data/tdf163818.odg
Normal file
Binary file not shown.
|
@ -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();
|
||||
|
||||
|
|
|
@ -1856,6 +1856,8 @@ bool ZipFile::checkSizeAndCRC( const ZipEntry& aEntry )
|
|||
{
|
||||
::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
|
||||
|
||||
try
|
||||
{
|
||||
sal_Int32 nCRC = 0;
|
||||
sal_Int64 nSize = 0;
|
||||
|
||||
|
@ -1871,6 +1873,11 @@ bool ZipFile::checkSizeAndCRC( const ZipEntry& aEntry )
|
|||
getSizeAndCRC( aEntry.nOffset, aEntry.nCompressedSize, &nSize, &nCRC );
|
||||
return ( aEntry.nSize == nSize && aEntry.nCrc == nCRC );
|
||||
}
|
||||
catch (uno::Exception const&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sal_Int32 ZipFile::getCRC( sal_Int64 nOffset, sal_Int64 nSize )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue