From 1f74259d4237a98db7aaa65c55a747f15a347b7c Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 27 Apr 2020 08:05:23 +1000 Subject: [PATCH] coverity 1462543 Logically dead code Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/11651) --- crypto/cms/cms_kari.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c index 4e837718dc..7372a94ecd 100644 --- a/crypto/cms/cms_kari.c +++ b/crypto/cms/cms_kari.c @@ -382,27 +382,27 @@ int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip, EVP_PKEY *r if (!cms_kari_create_ephemeral_key(kari, recipPubKey)) return 0; } else { - /* Use originator key */ - CMS_OriginatorIdentifierOrKey *oik = ri->d.kari->originator; + /* Use originator key */ + CMS_OriginatorIdentifierOrKey *oik = ri->d.kari->originator; - if (originatorPrivKey == NULL && originator == NULL) + if (originatorPrivKey == NULL || originator == NULL) return 0; - if (flags & CMS_USE_ORIGINATOR_KEYID) { - oik->type = CMS_OIK_KEYIDENTIFIER; - oik->d.subjectKeyIdentifier = ASN1_OCTET_STRING_new(); - if (oik->d.subjectKeyIdentifier == NULL) - return 0; - if (!cms_set1_keyid(&oik->d.subjectKeyIdentifier, originator)) - return 0; - } else { - oik->type = CMS_REK_ISSUER_SERIAL; - if (!cms_set1_ias(&oik->d.issuerAndSerialNumber, originator)) - return 0; - } - - if (!cms_kari_set_originator_private_key(kari, originatorPrivKey)) - return 0; + if (flags & CMS_USE_ORIGINATOR_KEYID) { + oik->type = CMS_OIK_KEYIDENTIFIER; + oik->d.subjectKeyIdentifier = ASN1_OCTET_STRING_new(); + if (oik->d.subjectKeyIdentifier == NULL) + return 0; + if (!cms_set1_keyid(&oik->d.subjectKeyIdentifier, originator)) + return 0; + } else { + oik->type = CMS_REK_ISSUER_SERIAL; + if (!cms_set1_ias(&oik->d.issuerAndSerialNumber, originator)) + return 0; + } + + if (!cms_kari_set_originator_private_key(kari, originatorPrivKey)) + return 0; } EVP_PKEY_up_ref(recipPubKey); -- 2.25.1