Test the result of CMS_RecipientInfo_ktri_get0_algs() before using its output in...
authorBrad Spencer <bspencer@blackberry.com>
Wed, 20 Dec 2017 17:41:14 +0000 (13:41 -0400)
committerBen Kaduk <kaduk@mit.edu>
Thu, 1 Mar 2018 15:17:41 +0000 (09:17 -0600)
CLA: trivial

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/4966)

(cherry picked from commit 178989b4a3ed714fa169cae5865c75f156ec9fdb)

crypto/rsa/rsa_ameth.c

index 5694140af82429d10af28979b43853668456219a..8f7f8da24f1f807cefc11de64af8fda6b2b17fb3 100644 (file)
@@ -773,7 +773,8 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
     EVP_PKEY_CTX *pkctx = CMS_RecipientInfo_get0_pkey_ctx(ri);
     int pad_mode = RSA_PKCS1_PADDING, rv = 0, labellen;
     unsigned char *label;
-    CMS_RecipientInfo_ktri_get0_algs(ri, NULL, NULL, &alg);
+    if (CMS_RecipientInfo_ktri_get0_algs(ri, NULL, NULL, &alg) <= 0)
+        return 0;
     if (pkctx) {
         if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0)
             return 0;