diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-03 22:40:07 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-02-09 15:19:00 +0100 |
commit | 5b6c866d522e7eef636a5fa4048c39c1ea60e466 (patch) | |
tree | 4a799c74af9e59ce2d572fb3ebc1153623906082 /package/source/xstor/owriteablestream.cxx | |
parent | b838986c6edfb4e5fb1e30bf47d8ad54ae2b4098 (diff) |
tdf#93389: keep encryption information for autorecovered MS formats
The autorecovery data is stored in ODF, regardless of the original
document format. When restoring, type detection generates ODF data,
which is stored in the media descriptor attached to document, even
after real filter was restored (see AutoRecovery::implts_openDocs).
If real filter is not ODF, then at the save time, it doesn't find
necessary information in encryption data, and makes not encrypted
package.
This patch adds both MS binary data, and OOXML data, to existing
ODF data for recovered password-protected documents (regardless of
their real filter).
TODO: only add required information to encryption data: pass real
filter name to DocPasswordHelper::requestAndVerifyDocPassword from
AutoRecovery::implts_openDocs.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86201
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit dd198398b6e5c84ab1255a90ef96e6445b66a64f)
Conflicts:
comphelper/source/misc/docpasswordhelper.cxx
Change-Id: I4717f067ad3c40167312b99eefef5584a467bfed
(cherry picked from commit 6017cdff264afc3b98beeba1330d6df28102fe7a)
Diffstat (limited to 'package/source/xstor/owriteablestream.cxx')
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 2f49e497dd47..19e28e9dcb33 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -79,9 +79,11 @@ struct WSInternalData_Impl namespace package { -bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 ) +bool PackageEncryptionDataLessOrEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 ) { - bool bResult = !aHash1.empty() && aHash1.size() == aHash2.size(); + // tdf#93389: aHash2 may contain more than in aHash1, if it contains also data for other package + // formats (as in case of autorecovery) + bool bResult = !aHash1.empty() && aHash1.size() <= aHash2.size(); for ( ::comphelper::SequenceAsHashMap::const_iterator aIter = aHash1.begin(); bResult && aIter != aHash1.end(); ++aIter ) @@ -1160,7 +1162,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod if ( m_bHasCachedEncryptionData ) { - if ( !::package::PackageEncryptionDatasEqual( m_aEncryptionData, aEncryptionData ) ) + if ( !::package::PackageEncryptionDataLessOrEqual( m_aEncryptionData, aEncryptionData ) ) throw packages::WrongPasswordException(); // the correct key must be set already |