Engine: Add NULL check.
authorPauli <paul.dale@oracle.com>
Wed, 20 Nov 2019 03:07:04 +0000 (13:07 +1000)
committerPauli <paul.dale@oracle.com>
Thu, 21 Nov 2019 04:31:58 +0000 (14:31 +1000)
Add NULL check for return from pkey_asn1_meths.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10473)

crypto/engine/tb_asnmth.c

index 5e356312a04e4fda2a51e603066aff0cb701a852..6289c225a53b0f7bf5a205bfeaa8e05fbddb836a 100644 (file)
@@ -147,7 +147,8 @@ const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
     nidcount = e->pkey_asn1_meths(e, NULL, &nids, 0);
     for (i = 0; i < nidcount; i++) {
         e->pkey_asn1_meths(e, &ameth, NULL, nids[i]);
-        if (((int)strlen(ameth->pem_str) == len)
+        if (ameth != NULL
+            && ((int)strlen(ameth->pem_str) == len)
             && strncasecmp(ameth->pem_str, str, len) == 0)
             return ameth;
     }