ENGINE_pkey_asn1_find_str(): don't assume an engine implements ASN1 method
[openssl.git] / crypto / engine / tb_asnmth.c
index 480267daabad91ed1ab65dfc0916d87e1da485c0..980c1277f9e6aa46236f639c8791d4a2f50f37c3 100644 (file)
@@ -170,7 +170,8 @@ static void look_str_cb(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg)
         ENGINE *e = sk_ENGINE_value(sk, i);
         EVP_PKEY_ASN1_METHOD *ameth;
         e->pkey_asn1_meths(e, &ameth, NULL, nid);
-        if (((int)strlen(ameth->pem_str) == lk->len)
+        if (ameth != NULL
+                && ((int)strlen(ameth->pem_str) == lk->len)
                 && strncasecmp(ameth->pem_str, lk->str, lk->len) == 0) {
             lk->e = e;
             lk->ameth = ameth;