Fix coverity CID #1465790 - Dereference after NULL check in evp_test.c
authorShane Lontis <shane.lontis@oracle.com>
Tue, 11 Aug 2020 05:36:49 +0000 (15:36 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 01:19:28 +0000 (11:19 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)

test/evp_test.c

index 958718b1ba79680f3487537c060e19306c4f57ba..adcfea0038320e5f2d870a3e0ff2743d7a138956 100644 (file)
@@ -1151,7 +1151,7 @@ static int mac_test_run_pkey(EVP_TEST *t)
                   OBJ_nid2sn(expected->type), expected->alg);
 
     if (expected->type == EVP_PKEY_CMAC) {
-        if (is_cipher_disabled(expected->alg)) {
+        if (expected->alg != NULL && is_cipher_disabled(expected->alg)) {
             TEST_info("skipping, PKEY CMAC '%s' is disabled", expected->alg);
             t->skip = 1;
             t->err = NULL;
@@ -1174,7 +1174,7 @@ static int mac_test_run_pkey(EVP_TEST *t)
         goto err;
     }
 
-    if (expected->type == EVP_PKEY_HMAC) {
+    if (expected->type == EVP_PKEY_HMAC && expected->alg != NULL) {
         if (is_digest_disabled(expected->alg)) {
             TEST_info("skipping, HMAC '%s' is disabled", expected->alg);
             t->skip = 1;