diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-09-19 20:15:18 +0200 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-09-21 14:47:37 +0200 |
commit | 44cea98d9006b08941e24c18d6eedbd01c3775c7 (patch) | |
tree | 985c5ca51e591748d61549ff0976a6f96c5c837b /crypto | |
parent | 296fc3ca5011cf6c9e332f5da46e6b80e9bc60ac (diff) |
Fix error handling in CRYPTO_get_ex_new_index
If an out of memory error happens when the index zero
is reserved in a newly created ip->meth stack object,
that reservation is not done in a second attempt, which makes
various X_set_ex_data overwrite the value of X_set_app_data.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22149)
(cherry picked from commit d4f22a915ac50570015a23ad794032c4fb9496cb)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ex_data.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/crypto/ex_data.c b/crypto/ex_data.c index 40223f06e4..455b63cd57 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -163,6 +163,8 @@ int ossl_crypto_get_ex_new_index_ex(OSSL_LIB_CTX *ctx, int class_index, * "app_data" routines use ex_data index zero. See RT 3710. */ if (ip->meth == NULL || !sk_EX_CALLBACK_push(ip->meth, NULL)) { + sk_EX_CALLBACK_free(ip->meth); + ip->meth = NULL; ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); goto err; } |