poppler/SignatureHandler.cc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 098d2d497b3d8cbc4fdf9eb68385bfbe2ee3e711
Author: Sune Vuorela <[email protected]>
Date:   Mon Mar 27 17:52:28 2023 +0200

    Fix crash in bad signature verification
    
    If the signature existing but too wrong for us to understand, we might
    not get the hashContext object created, so guard against that.
    
    This is fallout from 08c0766e9d.
    
    Note the SignHandler does not need the same guards; the hashContext is
    always present.

diff --git a/poppler/SignatureHandler.cc b/poppler/SignatureHandler.cc
index 64ac6594..99163000 100644
--- a/poppler/SignatureHandler.cc
+++ b/poppler/SignatureHandler.cc
@@ -780,12 +780,18 @@ SignatureSignHandler::SignatureSignHandler(const 
std::string &certNickname, Hash
 
 HashAlgorithm SignatureVerificationHandler::getHashAlgorithm() const
 {
-    return hashContext->getHashAlgorithm();
+    if (hashContext) {
+        return hashContext->getHashAlgorithm();
+    } else {
+        return HashAlgorithm::Unknown;
+    }
 }
 
 void SignatureVerificationHandler::updateHash(unsigned char *data_block, int 
data_len)
 {
-    hashContext->updateHash(data_block, data_len);
+    if (hashContext) {
+        hashContext->updateHash(data_block, data_len);
+    }
 }
 
 void SignatureSignHandler::updateHash(unsigned char *data_block, int data_len)

Reply via email to