aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/cms/cms_sd.c
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-08-06 12:11:13 +0200
committerDr. David von Oheimb <dev@ddvo.net>2022-01-14 18:47:20 +0100
commit04bc3c1277b8b20dc29f96933f7be592c0535aa8 (patch)
tree3a4f2681b5f814177017771b87a07d67f5029302 /crypto/cms/cms_sd.c
parent37b850738cbab74413d41033b2a4df1d69e1fa4a (diff)
downloadopenssl-04bc3c1277b8b20dc29f96933f7be592c0535aa8.tar.gz
Fix malloc failure handling of X509_ALGOR_set0()
Also update and slightly extend the respective documentation and simplify some code. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16251)
Diffstat (limited to 'crypto/cms/cms_sd.c')
-rw-r--r--crypto/cms/cms_sd.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c
index 7a77a0870a..8985be4fb4 100644
--- a/crypto/cms/cms_sd.c
+++ b/crypto/cms/cms_sd.c
@@ -354,6 +354,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
if (md == NULL) {
int def_nid;
+
if (EVP_PKEY_get_default_digest_nid(pk, &def_nid) <= 0)
goto err;
md = EVP_get_digestbynid(def_nid);
@@ -363,11 +364,6 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
}
}
- if (!md) {
- ERR_raise(ERR_LIB_CMS, CMS_R_NO_DIGEST_SET);
- goto err;
- }
-
if (md == NULL) {
ERR_raise(ERR_LIB_CMS, CMS_R_NO_DIGEST_SET);
goto err;
@@ -388,8 +384,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
}
if (i == sk_X509_ALGOR_num(sd->digestAlgorithms)) {
- alg = X509_ALGOR_new();
- if (alg == NULL)
+ if ((alg = X509_ALGOR_new()) == NULL)
goto merr;
X509_ALGOR_set_md(alg, md);
if (!sk_X509_ALGOR_push(sd->digestAlgorithms, alg)) {