summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-03 20:13:28 +0000
committerMichael Stahl <mstahl@redhat.com>2018-01-04 14:42:10 +0100
commit4e35c16ac29468ac8467da70cbe3c3a2685165ce (patch)
tree4ef2606446e794eefa3b4152ac1a89d8745bfbed /oox
parent2b8d6961b9539353b1b70a35460d8690ea10821d (diff)
ofz#4929 ensure min input len for openssl ciphers
openssl is not the default backend Change-Id: Id7bd77c1a12a15c0ebb4e7d758362c7778bfc2fd Reviewed-on: https://gerrit.libreoffice.org/47351 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/crypto/CryptTools.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/oox/source/crypto/CryptTools.cxx b/oox/source/crypto/CryptTools.cxx
index a80eaad63689..f1d4e9a8bf77 100644
--- a/oox/source/crypto/CryptTools.cxx
+++ b/oox/source/crypto/CryptTools.cxx
@@ -122,10 +122,20 @@ Decrypt::Decrypt(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, Crypto
const EVP_CIPHER* cipher = getCipher(type);
+ const size_t nMinKeySize = EVP_CIPHER_key_length(cipher);
+ if (key.size() < nMinKeySize)
+ key.resize(nMinKeySize, 0);
+
if (iv.empty())
EVP_DecryptInit_ex(&mContext, cipher, nullptr, key.data(), 0);
else
+ {
+ const size_t nMinIVSize = EVP_CIPHER_iv_length(cipher);
+ if (iv.size() < nMinIVSize)
+ iv.resize(nMinIVSize, 0);
+
EVP_DecryptInit_ex(&mContext, cipher, nullptr, key.data(), iv.data());
+ }
EVP_CIPHER_CTX_set_padding(&mContext, 0);
#endif