summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-10-21 17:12:28 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-10-24 07:52:50 +0200
commit865344152d8d99a6efcbb46bc7c530a6bab8c3de (patch)
tree13405f0ffd07b78d2a06cd9a03628db1f081f777 /oox
parentb5f8fa488c5380ef459a21cbe5413f52eeebab6f (diff)
Rather not put unencrypted doc in a tempfile
Keep it in memory instead Reviewed-on: https://gerrit.libreoffice.org/81253 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit bd3929da20b5a536b82b15af552864e7549f91ef) Reviewed-on: https://gerrit.libreoffice.org/81298 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit a2c94755d883ed807efa4a60302762cf4c6fbefe) Change-Id: I25e5cb7183a4d192938110323e27f2f5d1d006fc Reviewed-on: https://gerrit.libreoffice.org/81363 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/filterdetect.cxx30
1 files changed, 20 insertions, 10 deletions
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 1af982c07480..492f359a7ab4 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -346,16 +346,26 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript
}
else
{
- // create temporary file for unencrypted package
- Reference<XStream> xTempFile( TempFile::create(mxContext), UNO_QUERY_THROW );
- aDecryptor.decrypt( xTempFile );
-
- // store temp file in media descriptor to keep it alive
- rMediaDescriptor.setComponentDataEntry( "DecryptedPackage", Any( xTempFile ) );
-
- Reference<XInputStream> xDecryptedInputStream = xTempFile->getInputStream();
- if( lclIsZipPackage( mxContext, xDecryptedInputStream ) )
- return xDecryptedInputStream;
+ // create MemoryStream for unencrypted package - rather not put this in a tempfile
+ Reference<XStream> const xTempStream(
+ mxContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.comp.MemoryStream", mxContext),
+ UNO_QUERY_THROW);
+
+ // if decryption was unsuccessful (corrupted file or any other reason)
+ if (!aDecryptor.decrypt(xTempStream))
+ {
+ rMediaDescriptor[ MediaDescriptor::PROP_ABORTED() ] <<= true;
+ }
+ else
+ {
+ // store temp file in media descriptor to keep it alive
+ rMediaDescriptor.setComponentDataEntry( "DecryptedPackage", Any( xTempStream ) );
+
+ Reference<XInputStream> xDecryptedInputStream = xTempStream->getInputStream();
+ if( lclIsZipPackage( mxContext, xDecryptedInputStream ) )
+ return xDecryptedInputStream;
+ }
}
}
}