diff options
author | x2018 <xkernel.wang@foxmail.com> | 2021-10-22 22:50:27 +0800 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-10-27 08:38:30 +1000 |
commit | d146811f6cce155eeb1a87396943c953acb08fb6 (patch) | |
tree | 64740a768140dd293a2d4e5475e097ce3c7300ab /crypto/rsa/rsa_backend.c | |
parent | 1682a8524652c4f1386852f0d0c1dec75895b7da (diff) |
add checks for the return values of BN_new(), sk_RSA_PRIME_INFO_new_reserve(),
EVP_PKEY_CTX_new_from_pkey() and EVP_CIPHER_CTX_new().
Otherwise may result in memory errors.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16892)
(cherry picked from commit 9dddcd90a1350fa63486cbf3226c3eee79f9aff5)
Diffstat (limited to 'crypto/rsa/rsa_backend.c')
-rw-r--r-- | crypto/rsa/rsa_backend.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/crypto/rsa/rsa_backend.c b/crypto/rsa/rsa_backend.c index 85ad54e4cf..46283265d2 100644 --- a/crypto/rsa/rsa_backend.c +++ b/crypto/rsa/rsa_backend.c @@ -392,6 +392,8 @@ RSA *ossl_rsa_dup(const RSA *rsa, int selection) if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0 && (pnum = sk_RSA_PRIME_INFO_num(rsa->prime_infos)) > 0) { dupkey->prime_infos = sk_RSA_PRIME_INFO_new_reserve(NULL, pnum); + if (dupkey->prime_infos == NULL) + goto err; for (i = 0; i < pnum; i++) { const RSA_PRIME_INFO *pinfo = NULL; RSA_PRIME_INFO *duppinfo = NULL; |