Blob Blame History Raw
From 59f6c408ba822147fd4b9b47d84dab537fb8554d Mon Sep 17 00:00:00 2001
From: rpmbuild <rpmbuild@fedoraproject.org>
Date: Fri, 10 Aug 2018 08:26:23 +0100
Subject: [PATCH] Resolves: rhbz#1614419 crash in pptx nss usage under fips

---
 oox/source/crypto/CryptTools.cxx | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/oox/source/crypto/CryptTools.cxx b/oox/source/crypto/CryptTools.cxx
index 4bb3ec2..5ecf7b3 100644
--- a/oox/source/crypto/CryptTools.cxx
+++ b/oox/source/crypto/CryptTools.cxx
@@ -36,9 +36,12 @@ Crypto::~Crypto()
     EVP_CIPHER_CTX_cleanup( &mContext );
 #endif
 #if USE_TLS_NSS
-    PK11_DestroyContext( mContext, PR_TRUE );
-    PK11_FreeSymKey( mSymKey );
-    SECITEM_FreeItem( mSecParam, PR_TRUE );
+    if (mContext)
+        PK11_DestroyContext(mContext, PR_TRUE);
+    if (mSymKey)
+        PK11_FreeSymKey(mSymKey);
+    if (mSecParam)
+        SECITEM_FreeItem(mSecParam, PR_TRUE);
 #endif
 }
 
@@ -103,6 +106,8 @@ void Crypto::setupContext(vector<sal_uInt8>& key, vector<sal_uInt8>& iv, CryptoT
     keyItem.len  = key.size();
 
     mSymKey = PK11_ImportSymKey( pSlot, mechanism, PK11_OriginUnwrap, CKA_ENCRYPT, &keyItem, nullptr );
+    if (!mSymKey)
+        throw css::uno::RuntimeException("NSS SymKey failure", css::uno::Reference<css::uno::XInterface>());
     mSecParam = PK11_ParamFromIV( mechanism, pIvItem );
     mContext = PK11_CreateContextBySymKey( mechanism, operation, mSymKey, mSecParam );
 }
-- 
1.8.3.1