package/inc/ZipFile.hxx | 10 ++- package/source/zipapi/XUnbufferedStream.cxx | 17 +++--- package/source/zipapi/XUnbufferedStream.hxx | 4 + package/source/zipapi/ZipFile.cxx | 36 +++++++----- package/source/zipapi/ZipOutputStream.cxx | 3 + package/source/zippackage/ZipPackageStream.cxx | 70 +++++++++++++++++-------- package/source/zippackage/zipfileaccess.cxx | 4 - 7 files changed, 93 insertions(+), 51 deletions(-)
New commits: commit 33d55465d9f81863b88d649a46353cc4d19cd253 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Sep 12 18:24:27 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 13 11:32:38 2024 +0200 tdf#162823 package: fix loss of ODF encrypted basic macros The problem is that there is a ZipEntry ZipPackageStream::aEntry which does not necessarily correspond to the values read from the Zip central directory, because of a call to ZipPackageStream::setSize() in ZipPackageStream::successfullyWritten() to override nSize and nMethod for encrypted entries. This triggers the consistency checks in readLOC(), where this aEntry is passed. Refactor things so that ZipPackageStream::aEntry and thus hopefully all ZipEntry instances correspond to the Zip file's central directory. For encrypted entries, store the decompressed size (which is read from manifest.xml) in m_nOwnStreamOrigSize and pass it as a separate parameter to the ZipFile functions that need it, and ultimately to XUnbufferedStream, resolving multiple TODO comments. (regression from commit efae4fc42d5fe3c0a69757226f38efc10d101194) Change-Id: Ib6ea32595c6027b98da9196a2e2bd0a99b62a983 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173273 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index c52bfc7a0366..72b053363f61 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -78,12 +78,13 @@ private: ZipEntry const & rEntry, const ::rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, - bool bDecrypt, + ::std::optional<sal_Int64> oDecryptedSize, const bool bUseBufferedStream = true, const OUString& aMediaType = OUString() ); css::uno::Reference<css::io::XInputStream> checkValidPassword( ZipEntry const& rEntry, rtl::Reference<EncryptionData> const& rData, + sal_Int64 nDecryptedSize, rtl::Reference<comphelper::RefCountedMutex> const& rMutexHolder); bool checkSizeAndCRC( const ZipEntry& aEntry ); @@ -121,7 +122,7 @@ public: css::uno::Reference< css::io::XInputStream > getRawData( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, - bool bDecrypt, + ::std::optional<sal_Int64> oDecryptedSize, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder, const bool bUseBufferedStream = true ); @@ -162,18 +163,19 @@ public: css::uno::Reference< css::io::XInputStream > getInputStream( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, - bool bDecrypt, + ::std::optional<sal_Int64> oDecryptedSize, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); css::uno::Reference< css::io::XInputStream > getDataStream( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, - bool bDecrypt, + ::std::optional<sal_Int64> oEncryptedSize, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); css::uno::Reference< css::io::XInputStream > getWrappedRawStream( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, + sal_Int64 nDecryptedSize, const OUString& aMediaType, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx index dae87e632fd8..192958412d93 100644 --- a/package/source/zipapi/XUnbufferedStream.cxx +++ b/package/source/zipapi/XUnbufferedStream.cxx @@ -47,7 +47,7 @@ XUnbufferedStream::XUnbufferedStream( Reference < XInputStream > const & xNewZipStream, const ::rtl::Reference< EncryptionData >& rData, sal_Int8 nStreamMode, - bool bIsEncrypted, + ::std::optional<sal_Int64> const oDecryptedSize, const OUString& aMediaType, bool bRecoveryMode ) : maMutexHolder(std::move( aMutexHolder )) @@ -66,16 +66,17 @@ XUnbufferedStream::XUnbufferedStream( , mbCheckCRC(!bRecoveryMode) { mnZipCurrent = maEntry.nOffset; - sal_Int64 nSize; + sal_Int64 nSize; // data size in the zip file + assert(maEntry.nMethod != STORED || maEntry.nCompressedSize == maEntry.nSize); if ( mbRawStream ) { - mnZipSize = maEntry.nMethod == DEFLATED ? maEntry.nCompressedSize : maEntry.nSize; + mnZipSize = maEntry.nCompressedSize; nSize = mnZipSize; } else { - mnZipSize = maEntry.nSize; - nSize = maEntry.nMethod == DEFLATED ? maEntry.nCompressedSize : maEntry.nSize; + mnZipSize = oDecryptedSize ? *oDecryptedSize : maEntry.nSize; + nSize = maEntry.nCompressedSize; } if (mnZipSize < 0) @@ -88,7 +89,7 @@ XUnbufferedStream::XUnbufferedStream( ((rData->m_aSalt.hasElements() && (rData->m_oPBKDFIterationCount || rData->m_oArgon2Args)) || rData->m_aKey.hasElements()); - bool bMustDecrypt = nStreamMode == UNBUFF_STREAM_DATA && bHaveEncryptData && bIsEncrypted; + bool bMustDecrypt = nStreamMode == UNBUFF_STREAM_DATA && bHaveEncryptData && oDecryptedSize; if ( bMustDecrypt ) { @@ -97,7 +98,7 @@ XUnbufferedStream::XUnbufferedStream( mnBlockSize = ( rData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 16 : 1 ); } - if ( !(bHaveEncryptData && mbWrappedRaw && bIsEncrypted) ) + if (!(bHaveEncryptData && mbWrappedRaw && oDecryptedSize)) return; // if we have the data needed to decrypt it, but didn't want it decrypted (or @@ -111,7 +112,7 @@ XUnbufferedStream::XUnbufferedStream( rData->m_aDigest.getLength() + aMediaType.getLength() * sizeof( sal_Unicode ) ); sal_Int8 * pHeader = maHeader.getArray(); - ZipFile::StaticFillHeader( rData, rEntry.nSize, aMediaType, pHeader ); + ZipFile::StaticFillHeader(rData, *oDecryptedSize, aMediaType, pHeader); mnHeaderToRead = static_cast < sal_Int16 > ( maHeader.getLength() ); mnZipSize += mnHeaderToRead; } diff --git a/package/source/zipapi/XUnbufferedStream.hxx b/package/source/zipapi/XUnbufferedStream.hxx index af57706386c3..f3efe0aaecce 100644 --- a/package/source/zipapi/XUnbufferedStream.hxx +++ b/package/source/zipapi/XUnbufferedStream.hxx @@ -19,6 +19,8 @@ #ifndef INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX #define INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX +#include <optional> + #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/xml/crypto/XCipherContext.hpp> @@ -67,7 +69,7 @@ public: css::uno::Reference < css::io::XInputStream > const & xNewZipStream, const ::rtl::Reference< EncryptionData >& rData, sal_Int8 nStreamMode, - bool bIsEncrypted, + ::std::optional<sal_Int64> oDecryptedSize, const OUString& aMediaType, bool bRecoveryMode ); diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 5d223c57fad0..c5b3b5f9b5ca 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -541,6 +541,7 @@ bool ZipFile::StaticHasValidPassword( const uno::Reference< uno::XComponentConte uno::Reference<io::XInputStream> ZipFile::checkValidPassword( ZipEntry const& rEntry, ::rtl::Reference<EncryptionData> const& rData, + sal_Int64 const nDecryptedSize, rtl::Reference<comphelper::RefCountedMutex> const& rMutex) { if (rData.is() && rData->m_nEncAlg == xml::crypto::CipherID::AES_GCM_W3C) @@ -548,7 +549,7 @@ uno::Reference<io::XInputStream> ZipFile::checkValidPassword( try // the only way to find out: decrypt the whole stream, which will { // check the tag uno::Reference<io::XInputStream> const xRet = - createStreamForZipEntry(rMutex, rEntry, rData, UNBUFF_STREAM_DATA, true); + createStreamForZipEntry(rMutex, rEntry, rData, UNBUFF_STREAM_DATA, nDecryptedSize); // currently XBufferedStream reads the whole stream in its ctor (to // verify the tag) - in case this gets changed, explicitly seek here uno::Reference<io::XSeekable> const xSeek(xRet, uno::UNO_QUERY_THROW); @@ -581,7 +582,7 @@ uno::Reference<io::XInputStream> ZipFile::checkValidPassword( if (StaticHasValidPassword(m_xContext, aReadBuffer, rData)) { return createStreamForZipEntry( - rMutex, rEntry, rData, UNBUFF_STREAM_DATA, true); + rMutex, rEntry, rData, UNBUFF_STREAM_DATA, nDecryptedSize); } } @@ -720,14 +721,14 @@ uno::Reference< XInputStream > ZipFile::createStreamForZipEntry( ZipEntry const & rEntry, const ::rtl::Reference< EncryptionData > &rData, sal_Int8 nStreamMode, - bool bIsEncrypted, + ::std::optional<sal_Int64> const oDecryptedSize, const bool bUseBufferedStream, const OUString& aMediaType ) { ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() ); rtl::Reference< XUnbufferedStream > xSrcStream = new XUnbufferedStream( - m_xContext, aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode); + m_xContext, aMutexHolder, rEntry, xStream, rData, nStreamMode, oDecryptedSize, aMediaType, bRecoveryMode); if (!bUseBufferedStream) return xSrcStream; @@ -826,7 +827,7 @@ ZipEnumeration ZipFile::entries() uno::Reference< XInputStream > ZipFile::getInputStream( ZipEntry& rEntry, const ::rtl::Reference< EncryptionData > &rData, - bool bIsEncrypted, + ::std::optional<sal_Int64> const oDecryptedSize, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ) { ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() ); @@ -839,9 +840,11 @@ uno::Reference< XInputStream > ZipFile::getInputStream( ZipEntry& rEntry, bool bNeedRawStream = rEntry.nMethod == STORED; - if (bIsEncrypted && rData.is()) + if (oDecryptedSize && rData.is()) { - uno::Reference<XInputStream> const xRet(checkValidPassword(rEntry, rData, aMutexHolder)); + assert(oDecryptedSize); + uno::Reference<XInputStream> const xRet( + checkValidPassword(rEntry, rData, *oDecryptedSize, aMutexHolder)); if (xRet.is()) { return xRet; @@ -853,12 +856,12 @@ uno::Reference< XInputStream > ZipFile::getInputStream( ZipEntry& rEntry, rEntry, rData, bNeedRawStream ? UNBUFF_STREAM_RAW : UNBUFF_STREAM_DATA, - bIsEncrypted ); + oDecryptedSize); } uno::Reference< XInputStream > ZipFile::getDataStream( ZipEntry& rEntry, const ::rtl::Reference< EncryptionData > &rData, - bool bIsEncrypted, + ::std::optional<sal_Int64> const oDecryptedSize, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ) { ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() ); @@ -869,7 +872,7 @@ uno::Reference< XInputStream > ZipFile::getDataStream( ZipEntry& rEntry, // An exception must be thrown in case stream is encrypted and // there is no key or the key is wrong bool bNeedRawStream = false; - if ( bIsEncrypted ) + if (oDecryptedSize) { // in case no digest is provided there is no way // to detect password correctness @@ -880,7 +883,7 @@ uno::Reference< XInputStream > ZipFile::getDataStream( ZipEntry& rEntry, // check if we can decrypt it or not SAL_WARN_IF(rData->m_nEncAlg != xml::crypto::CipherID::AES_GCM_W3C && !rData->m_aDigest.hasElements(), "package", "Can't detect password correctness without digest!"); - uno::Reference<XInputStream> const xRet(checkValidPassword(rEntry, rData, aMutexHolder)); + uno::Reference<XInputStream> const xRet(checkValidPassword(rEntry, rData, *oDecryptedSize, aMutexHolder)); if (!xRet.is()) { throw packages::WrongPasswordException(THROW_WHERE); @@ -894,12 +897,12 @@ uno::Reference< XInputStream > ZipFile::getDataStream( ZipEntry& rEntry, rEntry, rData, bNeedRawStream ? UNBUFF_STREAM_RAW : UNBUFF_STREAM_DATA, - bIsEncrypted ); + oDecryptedSize); } uno::Reference< XInputStream > ZipFile::getRawData( ZipEntry& rEntry, const ::rtl::Reference< EncryptionData >& rData, - bool bIsEncrypted, + ::std::optional<sal_Int64> const oDecryptedSize, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder, const bool bUseBufferedStream ) { @@ -908,12 +911,14 @@ uno::Reference< XInputStream > ZipFile::getRawData( ZipEntry& rEntry, if ( rEntry.nOffset <= 0 ) readLOC( rEntry ); - return createStreamForZipEntry ( aMutexHolder, rEntry, rData, UNBUFF_STREAM_RAW, bIsEncrypted, bUseBufferedStream ); + return createStreamForZipEntry(aMutexHolder, rEntry, rData, + UNBUFF_STREAM_RAW, oDecryptedSize, bUseBufferedStream); } uno::Reference< XInputStream > ZipFile::getWrappedRawStream( ZipEntry& rEntry, const ::rtl::Reference< EncryptionData >& rData, + sal_Int64 const nDecryptedSize, const OUString& aMediaType, const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ) { @@ -925,7 +930,8 @@ uno::Reference< XInputStream > ZipFile::getWrappedRawStream( if ( rEntry.nOffset <= 0 ) readLOC( rEntry ); - return createStreamForZipEntry ( aMutexHolder, rEntry, rData, UNBUFF_STREAM_WRAPPEDRAW, true, true, aMediaType ); + return createStreamForZipEntry(aMutexHolder, rEntry, rData, + UNBUFF_STREAM_WRAPPEDRAW, nDecryptedSize, true, aMediaType); } sal_uInt64 ZipFile::readLOC(ZipEntry &rEntry) diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index 5f9a8e405427..da265c303b13 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -87,7 +87,10 @@ void ZipOutputStream::rawCloseEntry( bool bEncrypt ) writeDataDescriptor(*m_pCurrentEntry); if (bEncrypt) + { m_pCurrentEntry->nMethod = STORED; + assert(m_pCurrentEntry->nSize == m_pCurrentEntry->nCompressedSize); + } m_pCurrentEntry = nullptr; } diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 937a322c303c..4d6888c1cd27 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -133,6 +133,10 @@ void ZipPackageStream::setZipEntryOnLoading( const ZipEntry &rInEntry ) if ( aEntry.nMethod == STORED ) m_bToBeCompressed = false; + + // this is called first, parseManifest may overwrite it if it's encrypted + assert(m_nOwnStreamOrigSize == 0); + m_nOwnStreamOrigSize = aEntry.nSize; } uno::Reference< io::XInputStream > const & ZipPackageStream::GetOwnSeekStream() @@ -530,14 +534,11 @@ bool ZipPackageStream::saveChild( OSL_ENSURE( !m_bRawStream || !(bToBeCompressed || bToBeEncrypted), "The stream is already encrypted!" ); xSeek->seek ( m_bRawStream ? m_nMagicalHackPos : 0 ); ImplSetStoredData ( *pTempEntry, xStream ); - - // TODO/LATER: Get rid of hacks related to switching of Flag Method and Size properties! } else if ( bToBeEncrypted ) { // this is the correct original size - pTempEntry->nSize = xSeek->getLength(); - m_nOwnStreamOrigSize = pTempEntry->nSize; + m_nOwnStreamOrigSize = xSeek->getLength(); } xSeek->seek ( 0 ); @@ -893,10 +894,6 @@ void ZipPackageStream::successfullyWritten( ZipEntry const *pEntry ) // Then copy it back afterwards... aEntry = *pEntry; - // TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving ) - if ( m_bIsEncrypted ) - setSize( m_nOwnStreamOrigSize ); - aEntry.nOffset *= -1; } @@ -930,7 +927,13 @@ uno::Reference< io::XInputStream > ZipPackageStream::getRawData() { if ( IsPackageMember() ) { - return m_rZipPackage.getZipFile().getRawData( aEntry, GetEncryptionData(), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef(), false/*bUseBufferedStream*/ ); + ::std::optional<sal_Int64> oDecryptedSize; + if (m_bIsEncrypted) + { + oDecryptedSize.emplace(m_nOwnStreamOrigSize); + } + return m_rZipPackage.getZipFile().getRawData( aEntry, GetEncryptionData(), + oDecryptedSize, m_rZipPackage.GetSharedMutexRef(), false/*bUseBufferedStream*/ ); } else if ( GetOwnSeekStream().is() ) { @@ -957,7 +960,13 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream() { if ( IsPackageMember() ) { - return m_rZipPackage.getZipFile().getInputStream( aEntry, GetEncryptionData(), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() ); + ::std::optional<sal_Int64> oDecryptedSize; + if (m_bIsEncrypted) + { + oDecryptedSize.emplace(m_nOwnStreamOrigSize); + } + return m_rZipPackage.getZipFile().getInputStream(aEntry, GetEncryptionData(), + oDecryptedSize, m_rZipPackage.GetSharedMutexRef()); } else if ( GetOwnSeekStream().is() ) { @@ -992,9 +1001,16 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() if ( IsPackageMember() ) { uno::Reference< io::XInputStream > xResult; + ::std::optional<sal_Int64> oDecryptedSize; + if (m_bIsEncrypted) + { + oDecryptedSize.emplace(m_nOwnStreamOrigSize); + } try { - xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::None), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() ); + xResult = m_rZipPackage.getZipFile().getDataStream(aEntry, + GetEncryptionData(Bugs::None), oDecryptedSize, + m_rZipPackage.GetSharedMutexRef()); } catch( const packages::WrongPasswordException& ) { @@ -1006,7 +1022,9 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() SAL_WARN("package", "ZipPackageStream::getDataStream(): SHA1 mismatch, trying fallbacks..."); try { // tdf#114939 try with legacy StarOffice SHA1 bug - xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::WrongSHA1), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() ); + xResult = m_rZipPackage.getZipFile().getDataStream(aEntry, + GetEncryptionData(Bugs::WrongSHA1), oDecryptedSize, + m_rZipPackage.GetSharedMutexRef()); return xResult; } catch (const packages::WrongPasswordException&) @@ -1023,7 +1041,9 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() // force SHA256 and see if that works m_nImportedStartKeyAlgorithm = xml::crypto::DigestID::SHA256; - xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() ); + xResult = m_rZipPackage.getZipFile().getDataStream(aEntry, + GetEncryptionData(), oDecryptedSize, + m_rZipPackage.GetSharedMutexRef()); return xResult; } catch (const packages::WrongPasswordException&) @@ -1036,7 +1056,9 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() // workaround for the encrypted documents generated with the old OOo1.x bug. if ( !m_bUseWinEncoding ) { - xResult = m_rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(Bugs::WinEncodingWrongSHA1), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() ); + xResult = m_rZipPackage.getZipFile().getDataStream(aEntry, + GetEncryptionData(Bugs::WinEncodingWrongSHA1), + oDecryptedSize, m_rZipPackage.GetSharedMutexRef()); m_bUseWinEncoding = true; } else @@ -1072,7 +1094,8 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream() if ( !m_bIsEncrypted || !GetEncryptionData().is() ) throw packages::NoEncryptionException(THROW_WHERE ); - return m_rZipPackage.getZipFile().getWrappedRawStream( aEntry, GetEncryptionData(), msMediaType, m_rZipPackage.GetSharedMutexRef() ); + return m_rZipPackage.getZipFile().getWrappedRawStream(aEntry, GetEncryptionData(), + m_nOwnStreamOrigSize, msMediaType, m_rZipPackage.GetSharedMutexRef()); } else if ( GetOwnSeekStream().is() ) { @@ -1127,7 +1150,13 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getPlainRawStream( if ( IsPackageMember() ) { - return m_rZipPackage.getZipFile().getRawData( aEntry, GetEncryptionData(), m_bIsEncrypted, m_rZipPackage.GetSharedMutexRef() ); + ::std::optional<sal_Int64> oDecryptedSize; + if (m_bIsEncrypted) + { + oDecryptedSize.emplace(m_nOwnStreamOrigSize); + } + return m_rZipPackage.getZipFile().getRawData(aEntry, GetEncryptionData(), + oDecryptedSize, m_rZipPackage.GetSharedMutexRef()); } else if ( GetOwnSeekStream().is() ) { @@ -1167,7 +1196,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, } else if ( aPropertyName == "Size" ) { - if ( !( aValue >>= aEntry.nSize ) ) + if (!(aValue >>= m_nOwnStreamOrigSize)) throw IllegalArgumentException(THROW_WHERE "Wrong type for Size property!", uno::Reference< XInterface >(), 2 ); @@ -1300,7 +1329,7 @@ Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName ) } else if ( PropertyName == "Size" ) { - return Any(aEntry.nSize); + return Any(m_nOwnStreamOrigSize); } else if ( PropertyName == "Encrypted" ) { @@ -1328,10 +1357,9 @@ Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName ) void ZipPackageStream::setSize ( const sal_Int64 nNewSize ) { - if ( aEntry.nCompressedSize != nNewSize ) - aEntry.nMethod = DEFLATED; - aEntry.nSize = nNewSize; + m_nOwnStreamOrigSize = nNewSize; } + OUString ZipPackageStream::getImplementationName() { return u"ZipPackageStream"_ustr; diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx index 25944a23e3de..3d442d263817 100644 --- a/package/source/zippackage/zipfileaccess.cxx +++ b/package/source/zippackage/zipfileaccess.cxx @@ -267,7 +267,7 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const OUString& aName ) { xEntryStream = m_pZipFile->getDataStream((*aIter).second, ::rtl::Reference< EncryptionData >(), - false, + {}, m_aMutexHolder); } catch (const container::NoSuchElementException&) @@ -391,7 +391,7 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern( { uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second, ::rtl::Reference< EncryptionData >(), - false, + {}, m_aMutexHolder ) ); if ( !xEntryStream.is() )