diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-04-12 10:01:51 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2022-08-27 09:40:09 +0200 |
commit | 5639ee79bdc905c1b7ed308fcd29e515e4f01a50 (patch) | |
tree | 1244577a1904367b1886884cd0d590e99459ae0e /crypto/err | |
parent | 555dd9390ba56f1c400d3f067a2dfe7b00fbf7d3 (diff) |
ERR: Make CRYPTO_malloc() and friends report ERR_R_MALLOC_FAILURE
Fixes #6251
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/14833)
Diffstat (limited to 'crypto/err')
-rw-r--r-- | crypto/err/err.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c index 02fae89746..a6c5ff6132 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -199,16 +199,16 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) } #endif -static void ERR_STATE_free(ERR_STATE *s) +static void ERR_STATE_free(ERR_STATE *state) { int i; - if (s == NULL) + if (state == NULL) return; for (i = 0; i < ERR_NUM_ERRORS; i++) { - err_clear(s, i, 1); + err_clear(state, i, 1); } - OPENSSL_free(s); + CRYPTO_free(state, OPENSSL_FILE, OPENSSL_LINE); } DEFINE_RUN_ONCE_STATIC(do_err_strings_init) @@ -689,7 +689,9 @@ ERR_STATE *ossl_err_get_state_int(void) if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1)) return NULL; - if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) { + /* calling CRYPTO_zalloc(.., NULL, 0) prevents mem alloc error loop */ + state = CRYPTO_zalloc(sizeof(*state), NULL, 0); + if (state == NULL) { CRYPTO_THREAD_set_local(&err_thread_local, NULL); return NULL; } |