diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-12-12 21:07:46 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-12-13 16:51:28 +0100 |
commit | 6e3a6ca0500f38f082dd699802fec367cb559200 (patch) | |
tree | d3842e244ac3da38cb5adaa65632ecacd6519b67 /package/source/zipapi/ZipFile.cxx | |
parent | c358da05eb2a588b1bdf2fba96cc38f6f1e2221e (diff) |
package: move function down
Change-Id: I92742a28cf60a9dfc80001f9ca3c5551fe94472d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160677
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'package/source/zipapi/ZipFile.cxx')
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index f700b2722a71..1b4b7ec2e8f8 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -394,46 +394,6 @@ bool ZipFile::StaticFillData ( ::rtl::Reference< BaseEncryptionData > const & r return bOk; } -uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const rtl::Reference< comphelper::RefCountedMutex >& aMutexHolder, - const uno::Reference< uno::XComponentContext >& rxContext, - const uno::Reference< XInputStream >& xStream, - const ::rtl::Reference< EncryptionData > &rData ) -{ - if ( !rData.is() ) - throw ZipIOException("Encrypted stream without encryption data!" ); - - if ( !rData->m_aKey.hasElements() ) - throw packages::WrongPasswordException(THROW_WHERE ); - - uno::Reference< XSeekable > xSeek( xStream, UNO_QUERY ); - if ( !xSeek.is() ) - throw ZipIOException("The stream must be seekable!" ); - - // if we have a digest, then this file is an encrypted one and we should - // check if we can decrypt it or not - OSL_ENSURE( rData->m_aDigest.hasElements(), "Can't detect password correctness without digest!" ); - if ( rData->m_aDigest.hasElements() ) - { - sal_Int32 nSize = sal::static_int_cast< sal_Int32 >( xSeek->getLength() ); - if ( nSize > n_ConstDigestLength + 32 ) - nSize = n_ConstDigestLength + 32; - - // skip header - xSeek->seek( n_ConstHeaderSize + rData->m_aInitVector.getLength() + - rData->m_aSalt.getLength() + rData->m_aDigest.getLength() ); - - // Only want to read enough to verify the digest - Sequence < sal_Int8 > aReadBuffer ( nSize ); - - xStream->readBytes( aReadBuffer, nSize ); - - if ( !StaticHasValidPassword( rxContext, aReadBuffer, rData ) ) - throw packages::WrongPasswordException(THROW_WHERE ); - } - - return new XUnbufferedStream( aMutexHolder, xStream, rData ); -} - #if 0 // for debugging purposes void CheckSequence( const uno::Sequence< sal_Int8 >& aSequence ) @@ -670,6 +630,47 @@ uno::Reference< XInputStream > ZipFile::createStreamForZipEntry( return xBufStream; } +uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( + const rtl::Reference<comphelper::RefCountedMutex>& rMutexHolder, + const uno::Reference<uno::XComponentContext>& rxContext, + const uno::Reference<XInputStream>& xStream, + const ::rtl::Reference<EncryptionData> &rData) +{ + if (!rData.is()) + throw ZipIOException("Encrypted stream without encryption data!" ); + + if (!rData->m_aKey.hasElements()) + throw packages::WrongPasswordException(THROW_WHERE); + + uno::Reference<XSeekable> xSeek(xStream, UNO_QUERY); + if (!xSeek.is()) + throw ZipIOException("The stream must be seekable!"); + + // if we have a digest, then this file is an encrypted one and we should + // check if we can decrypt it or not + OSL_ENSURE(rData->m_aDigest.hasElements(), "Can't detect password correctness without digest!"); + if (rData->m_aDigest.hasElements()) + { + sal_Int32 nSize = sal::static_int_cast<sal_Int32>(xSeek->getLength()); + if (nSize > n_ConstDigestLength + 32) + nSize = n_ConstDigestLength + 32; + + // skip header + xSeek->seek(n_ConstHeaderSize + rData->m_aInitVector.getLength() + + rData->m_aSalt.getLength() + rData->m_aDigest.getLength()); + + // Only want to read enough to verify the digest + Sequence<sal_Int8> aReadBuffer(nSize); + + xStream->readBytes(aReadBuffer, nSize); + + if (!StaticHasValidPassword(rxContext, aReadBuffer, rData)) + throw packages::WrongPasswordException(THROW_WHERE); + } + + return new XUnbufferedStream(rMutexHolder, xStream, rData); +} + ZipEnumeration ZipFile::entries() { return aEntries; |