Skip to content

Commit

Permalink
Fix error handling in CRYPTO_get_ex_new_index
Browse files Browse the repository at this point in the history
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 #22149)
  • Loading branch information
bernd-edlinger committed Sep 21, 2023
1 parent 8c040c0 commit d4f22a9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crypto/ex_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,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_CRYPTO_LIB);
goto err;
}
Expand Down

0 comments on commit d4f22a9

Please sign in to comment.