summaryrefslogtreecommitdiffstats
path: root/package/source/zippackage
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:54 +0000
commitadb203bc05e3e36173cbd46b9951f79821a81799 (patch)
tree6e6739df9b3f0a567330a0dd7ee0e03ae70876a3 /package/source/zippackage
parentAdding debian version 4:24.2.0-3. (diff)
downloadlibreoffice-adb203bc05e3e36173cbd46b9951f79821a81799.tar.xz
libreoffice-adb203bc05e3e36173cbd46b9951f79821a81799.zip
Merging upstream version 4:24.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'package/source/zippackage')
-rw-r--r--package/source/zippackage/ZipPackage.cxx17
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx10
2 files changed, 25 insertions, 2 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 02f7cf71e8..0f3fa6ff7d 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -171,6 +171,7 @@ void ZipPackage::parseManifest()
return;
bool bManifestParsed = false;
+ ::std::optional<OUString> oFirstVersion;
static constexpr OUString sMeta (u"META-INF"_ustr);
if ( m_xRootFolder->hasByName( sMeta ) )
{
@@ -216,7 +217,13 @@ void ZipPackage::parseManifest()
if ( rValue.Name == sPropFullPath )
rValue.Value >>= sPath;
else if ( rValue.Name == sPropVersion )
+ {
rValue.Value >>= sVersion;
+ if (!oFirstVersion)
+ {
+ oFirstVersion.emplace(sVersion);
+ }
+ }
else if ( rValue.Name == sPropMediaType )
rValue.Value >>= sMediaType;
else if ( rValue.Name == sPropSalt )
@@ -457,6 +464,11 @@ void ZipPackage::parseManifest()
{
// accept only types that look similar to own mediatypes
m_xRootFolder->SetMediaType( aPackageMediatype );
+ // also set version explicitly
+ if (oFirstVersion && m_xRootFolder->GetVersion().isEmpty())
+ {
+ m_xRootFolder->SetVersion(*oFirstVersion);
+ }
// if there is an encrypted inner package, there is no root
// document, because instead there is a package, and it is not
// an error
@@ -1716,6 +1728,11 @@ uno::Sequence< sal_Int8 > ZipPackage::GetEncryptionKey()
for ( const auto& rKey : std::as_const(m_aStorageEncryptionKeys) )
if ( rKey.Name == aNameToFind )
rKey.Value >>= aResult;
+
+ if (!aResult.hasElements() && m_aStorageEncryptionKeys.hasElements())
+ { // tdf#159519 sanity check
+ throw uno::RuntimeException(THROW_WHERE "Expected key is missing!");
+ }
}
else
aResult = m_aEncryptionKey;
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index d3068a6665..a5d4a0f7ce 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -592,8 +592,14 @@ bool ZipPackageStream::saveChild(
uno::Sequence<sal_Int8> aSalt(16);
// note: for GCM it's particularly important that IV is unique
uno::Sequence<sal_Int8> aVector(GetIVSize());
- rtl_random_getBytes ( rRandomPool, aSalt.getArray(), 16 );
- rtl_random_getBytes ( rRandomPool, aVector.getArray(), aVector.getLength() );
+ if (rtl_random_getBytes(rRandomPool, aSalt.getArray(), 16) != rtl_Random_E_None)
+ {
+ throw uno::RuntimeException("rtl_random_getBytes failed");
+ }
+ if (rtl_random_getBytes(rRandomPool, aVector.getArray(), aVector.getLength()) != rtl_Random_E_None)
+ {
+ throw uno::RuntimeException("rtl_random_getBytes failed");
+ }
if ( !m_bHaveOwnKey )
{
m_aEncryptionKey = rEncryptionKey;