summaryrefslogtreecommitdiffstats
path: root/crypto/cms
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2020-04-27 07:48:32 +1000
committerPauli <paul.dale@oracle.com>2020-04-30 20:21:33 +1000
commit3e47e7b454fb5e51c4e7efa98f40ea94d6e9c1fa (patch)
treed97fced84865a11a248d65378e6fb654826d7384 /crypto/cms
parentba61a0e60ff8d645d41e0bf4d65e753adca18b24 (diff)
coverity 1462567: Null pointer dereferences
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11651)
Diffstat (limited to 'crypto/cms')
-rw-r--r--crypto/cms/cms_kari.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c
index 7372a94ecd..a2149ce002 100644
--- a/crypto/cms/cms_kari.c
+++ b/crypto/cms/cms_kari.c
@@ -415,7 +415,7 @@ static int cms_wrap_init(CMS_KeyAgreeRecipientInfo *kari,
{
EVP_CIPHER_CTX *ctx = kari->ctx;
const EVP_CIPHER *kekcipher;
- int keylen = EVP_CIPHER_key_length(cipher);
+ int keylen;
int ret;
/* If a suitable wrap algorithm is already set nothing to do */
@@ -425,8 +425,10 @@ static int cms_wrap_init(CMS_KeyAgreeRecipientInfo *kari,
return 0;
return 1;
}
- else if (cipher != NULL
- && (EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_GET_WRAP_CIPHER)) {
+ if (cipher == NULL)
+ return 0;
+ keylen = EVP_CIPHER_key_length(cipher);
+ if ((EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_GET_WRAP_CIPHER) != 0) {
ret = EVP_CIPHER_meth_get_ctrl(cipher)(NULL, EVP_CTRL_GET_WRAP_CIPHER,
0, &kekcipher);
if (ret <= 0)