coverity 1462546 Dereference after null check
authorPauli <paul.dale@oracle.com>
Sun, 26 Apr 2020 22:26:39 +0000 (08:26 +1000)
committerPauli <paul.dale@oracle.com>
Thu, 30 Apr 2020 10:21:31 +0000 (20:21 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11651)

crypto/evp/m_sigver.c

index 829b861ed2fe6e1fb454a914077119c9708f2e49..c77683a69d205a8c5b49b676d8b1f3084cdb639c 100644 (file)
@@ -347,11 +347,13 @@ int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
                                                         data, dsize);
 
  legacy:
                                                         data, dsize);
 
  legacy:
-    /* do_sigver_init() checked that |digest_custom| is non-NULL */
-    if (pctx->flag_call_digest_custom
-        && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx))
-        return 0;
-    pctx->flag_call_digest_custom = 0;
+    if (pctx != NULL) {
+        /* do_sigver_init() checked that |digest_custom| is non-NULL */
+        if (pctx->flag_call_digest_custom
+            && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx))
+            return 0;
+        pctx->flag_call_digest_custom = 0;
+    }
 
     return EVP_DigestUpdate(ctx, data, dsize);
 }
 
     return EVP_DigestUpdate(ctx, data, dsize);
 }