Certain functions are automatically called during auto-deinit in order
to deallocate resources. However, if we have never entered a function which
marks lib crypto as inited then they never get called. This can happen if
the user only ever makes use of a small sub-set of functions that don't hit
the auto-init code.
This commit ensures all such resources deallocated by these functions also
init libcrypto when they are initially allocated.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Ben Laurie <ben@openssl.org>
(cherry picked from commit
135648bcd0e9db029582d3d7627a90a1b566c5d6)
DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init)
{
+ OPENSSL_init_crypto(0, NULL);
bio_lookup_lock = CRYPTO_THREAD_lock_new();
return bio_lookup_lock != NULL;
}
DEFINE_RUN_ONCE(do_engine_lock_init)
{
+ OPENSSL_init_crypto(0, NULL);
global_engine_lock = CRYPTO_THREAD_lock_new();
return global_engine_lock != NULL;
}
DEFINE_RUN_ONCE_STATIC(do_err_strings_init)
{
+ OPENSSL_init_crypto(0, NULL);
err_string_lock = CRYPTO_THREAD_lock_new();
return err_string_lock != NULL;
}
DEFINE_RUN_ONCE_STATIC(do_ex_data_init)
{
+ OPENSSL_init_crypto(0, NULL);
ex_data_lock = CRYPTO_THREAD_lock_new();
return ex_data_lock != NULL;
}
DEFINE_RUN_ONCE_STATIC(do_rand_lock_init)
{
+ OPENSSL_init_crypto(0, NULL);
rand_lock = CRYPTO_THREAD_lock_new();
rand_tmp_lock = CRYPTO_THREAD_lock_new();
return rand_lock != NULL && rand_tmp_lock != NULL;