From: Caolán McNamara Date: Mon, 16 Mar 2026 17:22:23 +0000 (+0000) Subject: [PATCH] Conform AlignEngine parsing to what section 2.3.4.10 of the spec has X-Git-Tag: archive/raspbian/4%25.2.3-2+rpi1+deb13u6^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c2ddbb7e676d84da3005d3b348ae01effe585359;p=libreoffice.git [PATCH] Conform AlignEngine parsing to what section 2.3.4.10 of the spec has Change-Id: Ibb9162b1ce7993ef74665ec0329c95b423fa8174 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201944 Reviewed-by: Adolfo Jayme Barrientos Tested-by: Jenkins Gbp-Pq: Name Conform-AlignEngine-parsing-to-spec.diff --- diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx index 6b552620f24..54af89de5b1 100644 --- a/oox/source/crypto/AgileEngine.cxx +++ b/oox/source/crypto/AgileEngine.cxx @@ -8,6 +8,8 @@ * */ +#include +#include #include #include @@ -547,8 +549,21 @@ bool AgileEngine::readEncryptionInfo(uno::Reference & rxInputS if (0 > mInfo.spinCount || mInfo.spinCount > 10000000) return false; - if (1 > mInfo.saltSize|| mInfo.saltSize > 65536) // Check + // [MS-OFFCRYPTO] 2.3.4.10: saltSize "MUST be at least 1 and no greater than 65,536" + if (1 > mInfo.saltSize || mInfo.saltSize > 65536) + { + SAL_WARN("oox", "AgileEngine::readEncryptionInfo(): saltSize out of range: " << mInfo.saltSize); + return false; + } + + // [MS-OFFCRYPTO] 2.3.4.10: "The number of bytes required to decode the saltValue + // attribute MUST be equal to the value of the saltSize attribute" + if (mInfo.keyDataSalt.size() != o3tl::make_unsigned(mInfo.saltSize)) + { + SAL_WARN("oox", "AgileEngine::readEncryptionInfo(): keyDataSalt size " << mInfo.keyDataSalt.size() + << " does not match saltSize " << mInfo.saltSize); return false; + } // AES 128 CBC with SHA1 if (mInfo.keyBits == 128 &&