]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
x509: fix coverity 1474471: NULL pointer dereference
authorPauli <pauli@openssl.org>
Mon, 29 Mar 2021 02:28:10 +0000 (12:28 +1000)
committerTomas Mraz <tomas@openssl.org>
Tue, 30 Mar 2021 16:57:29 +0000 (18:57 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14716)

crypto/x509/x_all.c

index c5e0c0b1ecbf1432b7b67cf9649fac352a065b9b..042425456c6d79d99367a97496b0efe7323b647f 100644 (file)
@@ -434,8 +434,11 @@ ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert)
 int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
                     unsigned char *md, unsigned int *len)
 {
-    if (type != NULL
-            && EVP_MD_is_a(type, SN_sha1)
+    if (type == NULL) {
+        ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+    if (EVP_MD_is_a(type, SN_sha1)
             && (data->flags & EXFLAG_SET) != 0
             && (data->flags & EXFLAG_NO_FINGERPRINT) == 0) {
         /* Asking for SHA1; always computed in CRL d2i. */