coverity 1462543 Logically dead code
authorPauli <paul.dale@oracle.com>
Sun, 26 Apr 2020 22:05:23 +0000 (08:05 +1000)
committerPauli <paul.dale@oracle.com>
Thu, 30 Apr 2020 10:21:31 +0000 (20:21 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11651)

crypto/cms/cms_kari.c

index 4e837718dcb4c91bd360e31de455d623bc44407e..7372a94ecd77e63181d8b1b531ae48d460998a29 100644 (file)
@@ -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);