summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7
diff options
context:
space:
mode:
authorDr. David von Oheimb <dev@ddvo.net>2023-10-20 21:00:10 +0200
committerHugo Landau <hlandau@openssl.org>2023-10-26 16:03:48 +0100
commitd7ad09da778bcc0090a7cdfd87edb56eea22382b (patch)
tree8f1a0bafa5a0ba49c1dbcf84e1dc8214dbaf1f12 /crypto/pkcs7
parentf03ce9e0194ab1b5422bc582eb81b8babaef49c5 (diff)
CMS and PKCS7: fix handlling of EVP_PKEY_get_size() failure
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22459)
Diffstat (limited to 'crypto/pkcs7')
-rw-r--r--crypto/pkcs7/pk7_doit.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index 43ea2a9b60..c753a0880b 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -834,10 +834,9 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
goto err;
} else {
unsigned char *abuf = NULL;
- unsigned int abuflen;
- abuflen = EVP_PKEY_get_size(si->pkey);
- abuf = OPENSSL_malloc(abuflen);
- if (abuf == NULL)
+ unsigned int abuflen = EVP_PKEY_get_size(si->pkey);
+
+ if (abuflen == 0 || (abuf = OPENSSL_malloc(abuflen)) == NULL)
goto err;
if (!EVP_SignFinal_ex(ctx_tmp, abuf, &abuflen, si->pkey,