From 311f02ac1129f30053974cc8130410e576b0981c Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Wed, 11 Jan 2017 17:55:34 +0100 Subject: [PATCH] Check for error from NSS in SignatureHandler construct. And cascading effects in other SignalHandler members. https://bugs.freedesktop.org/show_bug.cgi?id=99363 --- poppler/SignatureHandler.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/poppler/SignatureHandler.cc b/poppler/SignatureHandler.cc index a5132a48..15c9321c 100644 --- a/poppler/SignatureHandler.cc +++ b/poppler/SignatureHandler.cc @@ -105,7 +105,8 @@ void SignatureHandler::init_nss() SignatureHandler::SignatureHandler(unsigned char *p7, int p7_length) - : CMSMessage(NULL), + : hash_context(NULL), + CMSMessage(NULL), CMSSignedData(NULL), CMSSignerInfo(NULL), temp_certs(NULL) @@ -115,8 +116,10 @@ SignatureHandler::SignatureHandler(unsigned char *p7, int p7_length) CMSitem.len = p7_length; CMSMessage = CMS_MessageCreate(&CMSitem); CMSSignedData = CMS_SignedDataCreate(CMSMessage); - CMSSignerInfo = CMS_SignerInfoCreate(CMSSignedData); - hash_context = initHashContext(); + if (CMSSignedData) { + CMSSignerInfo = CMS_SignerInfoCreate(CMSSignedData); + hash_context = initHashContext(); + } } HASHContext * SignatureHandler::initHashContext() @@ -131,7 +134,9 @@ HASHContext * SignatureHandler::initHashContext() void SignatureHandler::updateHash(unsigned char * data_block, int data_len) { - HASH_Update(hash_context, data_block, data_len); + if (hash_context) { + HASH_Update(hash_context, data_block, data_len); + } } SignatureHandler::~SignatureHandler() -- 2.11.0