summaryrefslogtreecommitdiffstats
path: root/crypto/init.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-02-09 10:55:21 +0000
committerMatt Caswell <matt@openssl.org>2016-02-09 15:11:38 +0000
commitbf24111bb2cf37b609fecdbe81660ecfd460e998 (patch)
tree4815da4bea62bc39b1076015ae9a53f6ac7a3452 /crypto/init.c
parent8b75603cc0ce8f4d9deb7218fbd905d3fc73a4c0 (diff)
Avoid a race condition in loading config settings
A race condition can occur when sending config settings to OPENSSL_INIT_crypto_library_start() Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/init.c')
-rw-r--r--crypto/init.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/init.c b/crypto/init.c
index bce8438b95..1bfde6973c 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -679,13 +679,17 @@ void OPENSSL_INIT_crypto_library_start(uint64_t opts,
}
if (opts & OPENSSL_INIT_LOAD_CONFIG) {
+ CRYPTO_w_lock(CRYPTO_LOCK_INIT);
if (settings != NULL) {
const OPENSSL_INIT_SETTINGS *curr;
curr = ossl_init_get_setting(settings,
OPENSSL_INIT_SET_CONF_FILENAME);
- config_filename = curr == NULL ? NULL : curr->value.type_string;
+ config_filename = (curr == NULL) ? NULL : curr->value.type_string;
+ } else {
+ config_filename = NULL;
}
ossl_init_once_run(&config, ossl_init_config);
+ CRYPTO_w_unlock(CRYPTO_LOCK_INIT);
}
if (opts & OPENSSL_INIT_ASYNC) {