Coverity CID 1444963: Null pointer dereferences
authorPauli <paul.dale@oracle.com>
Tue, 7 May 2019 00:18:29 +0000 (10:18 +1000)
committerPauli <paul.dale@oracle.com>
Tue, 7 May 2019 23:35:52 +0000 (09:35 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8888)

crypto/evp/evp_enc.c

index d7ba7dd..a2f1260 100644 (file)
@@ -620,7 +620,11 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
         return 0;
     }
 
-    if (ctx->cipher == NULL || ctx->cipher->prov == NULL)
+    if (ctx->cipher == NULL) {
+        EVPerr(EVP_F_EVP_ENCRYPTFINAL_EX, EVP_R_NO_CIPHER_SET);
+        return 0;
+    }
+    if (ctx->cipher->prov == NULL)
         goto legacy;
 
     blocksize = EVP_CIPHER_CTX_block_size(ctx);