mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
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)
This commit is contained in:
parent
f03ce9e019
commit
d7ad09da77
@ -764,8 +764,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms,
|
|||||||
md = computed_md;
|
md = computed_md;
|
||||||
}
|
}
|
||||||
siglen = EVP_PKEY_get_size(si->pkey);
|
siglen = EVP_PKEY_get_size(si->pkey);
|
||||||
sig = OPENSSL_malloc(siglen);
|
if (siglen == 0 || (sig = OPENSSL_malloc(siglen)) == NULL)
|
||||||
if (sig == NULL)
|
|
||||||
goto err;
|
goto err;
|
||||||
if (EVP_PKEY_sign(pctx, sig, &siglen, md, mdlen) <= 0) {
|
if (EVP_PKEY_sign(pctx, sig, &siglen, md, mdlen) <= 0) {
|
||||||
OPENSSL_free(sig);
|
OPENSSL_free(sig);
|
||||||
@ -780,8 +779,8 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms,
|
|||||||
ERR_raise(ERR_LIB_CMS, CMS_R_OPERATION_UNSUPPORTED);
|
ERR_raise(ERR_LIB_CMS, CMS_R_OPERATION_UNSUPPORTED);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
sig = OPENSSL_malloc(EVP_PKEY_get_size(si->pkey));
|
siglen = EVP_PKEY_get_size(si->pkey);
|
||||||
if (sig == NULL)
|
if (siglen == 0 || (sig = OPENSSL_malloc(siglen)) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
if (!EVP_SignFinal_ex(mctx, sig, &siglen, si->pkey,
|
if (!EVP_SignFinal_ex(mctx, sig, &siglen, si->pkey,
|
||||||
ossl_cms_ctx_get0_libctx(ctx),
|
ossl_cms_ctx_get0_libctx(ctx),
|
||||||
|
@ -834,10 +834,9 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
|
|||||||
goto err;
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
unsigned char *abuf = NULL;
|
unsigned char *abuf = NULL;
|
||||||
unsigned int abuflen;
|
unsigned int abuflen = EVP_PKEY_get_size(si->pkey);
|
||||||
abuflen = EVP_PKEY_get_size(si->pkey);
|
|
||||||
abuf = OPENSSL_malloc(abuflen);
|
if (abuflen == 0 || (abuf = OPENSSL_malloc(abuflen)) == NULL)
|
||||||
if (abuf == NULL)
|
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!EVP_SignFinal_ex(ctx_tmp, abuf, &abuflen, si->pkey,
|
if (!EVP_SignFinal_ex(ctx_tmp, abuf, &abuflen, si->pkey,
|
||||||
|
Loading…
Reference in New Issue
Block a user