diff options
author | Richard Levitte <levitte@openssl.org> | 2016-07-19 19:42:11 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-07-19 23:49:54 +0200 |
commit | c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e (patch) | |
tree | e4e16df15de0263a21427c92ae21d20dc98e3c19 /crypto/engine/eng_list.c | |
parent | Define a few internal macros for easy use of run_once functions (diff) | |
download | openssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.tar.xz openssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.zip |
Change all our uses of CRYPTO_THREAD_run_once to use RUN_ONCE instead
That way, we have a way to check if the init function was successful
or not.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto/engine/eng_list.c')
-rw-r--r-- | crypto/engine/eng_list.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index a7252e930b..934389f74e 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -136,7 +136,11 @@ ENGINE *ENGINE_get_first(void) { ENGINE *ret; - CRYPTO_THREAD_run_once(&engine_lock_init, do_engine_lock_init); + if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) { + ENGINEerr(ENGINE_F_ENGINE_GET_FIRST, ERR_R_MALLOC_FAILURE); + return NULL; + } + CRYPTO_THREAD_write_lock(global_engine_lock); ret = engine_list_head; if (ret) { @@ -151,7 +155,11 @@ ENGINE *ENGINE_get_last(void) { ENGINE *ret; - CRYPTO_THREAD_run_once(&engine_lock_init, do_engine_lock_init); + if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) { + ENGINEerr(ENGINE_F_ENGINE_GET_LAST, ERR_R_MALLOC_FAILURE); + return NULL; + } + CRYPTO_THREAD_write_lock(global_engine_lock); ret = engine_list_tail; if (ret) { @@ -279,7 +287,11 @@ ENGINE *ENGINE_by_id(const char *id) ENGINEerr(ENGINE_F_ENGINE_BY_ID, ERR_R_PASSED_NULL_PARAMETER); return NULL; } - CRYPTO_THREAD_run_once(&engine_lock_init, do_engine_lock_init); + if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) { + ENGINEerr(ENGINE_F_ENGINE_BY_ID, ERR_R_MALLOC_FAILURE); + return NULL; + } + CRYPTO_THREAD_write_lock(global_engine_lock); iterator = engine_list_head; while (iterator && (strcmp(id, iterator->id) != 0)) |