diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-06-28 17:37:39 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-07-01 11:20:51 +0200 |
commit | d840f07bcdfc3910de5aa327a245866a67f94799 (patch) | |
tree | 638c017b776ab9e686e5c37cdaed2eee72355943 /crypto/conf | |
parent | 30b2c3592e8511b60d44f93eb657a1ecb3662c08 (diff) |
Avoid crashing if CONF_modules_unload() is called after OPENSSL_cleanup()
Although this is basically an incorrect API call it was not crashing
before and it might happen inadvertently if CONF_modules_unload()
is called from a destructor for example.
Fixes #18669
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18673)
Diffstat (limited to 'crypto/conf')
-rw-r--r-- | crypto/conf/conf_mod.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index c6b8696388..2de47e8e42 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -521,7 +521,9 @@ static int conf_modules_finish_int(void) if (!RUN_ONCE(&init_module_list_lock, do_init_module_list_lock)) return 0; - if (!CRYPTO_THREAD_write_lock(module_list_lock)) + /* If module_list_lock is NULL here it means we were already unloaded */ + if (module_list_lock == NULL + || !CRYPTO_THREAD_write_lock(module_list_lock)) return 0; while (sk_CONF_IMODULE_num(initialized_modules) > 0) { |