summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/crypto_init.c
diff options
context:
space:
mode:
authorjsing <>2018-11-28 15:51:32 +0000
committerjsing <>2018-11-28 15:51:32 +0000
commit9929fb92ec5eef94190c43b92a4901712953b553 (patch)
tree89f569e7886b1100fcaafc0b6975a9aec0badcd4 /src/lib/libcrypto/crypto_init.c
parent1ea05fdbfec108dafe131398c5f4f7d549fe0fda (diff)
downloadopenbsd-9929fb92ec5eef94190c43b92a4901712953b553.tar.gz
openbsd-9929fb92ec5eef94190c43b92a4901712953b553.tar.bz2
openbsd-9929fb92ec5eef94190c43b92a4901712953b553.zip
Correct lock initialisation for libcrypto.
The current crypto_lock_init() function is not called early enough, meaning that locks are already in use before it gets called. Worse, locks could be in use when they are then initialised. Furthermore, since functions like CRYPTO_lock() are public API, these could be called directly bypassing initialisation. Avoid these issues by using static initialisers. ok bcook@
Diffstat (limited to 'src/lib/libcrypto/crypto_init.c')
-rw-r--r--src/lib/libcrypto/crypto_init.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/libcrypto/crypto_init.c b/src/lib/libcrypto/crypto_init.c
index 3745e2e718..67e7920890 100644
--- a/src/lib/libcrypto/crypto_init.c
+++ b/src/lib/libcrypto/crypto_init.c
@@ -23,6 +23,7 @@
23#include <openssl/conf.h> 23#include <openssl/conf.h>
24#include <openssl/evp.h> 24#include <openssl/evp.h>
25#include <openssl/err.h> 25#include <openssl/err.h>
26
26#include "cryptlib.h" 27#include "cryptlib.h"
27 28
28int OpenSSL_config(const char *); 29int OpenSSL_config(const char *);
@@ -30,17 +31,15 @@ int OpenSSL_no_config(void);
30 31
31static pthread_t crypto_init_thread; 32static pthread_t crypto_init_thread;
32 33
33void crypto_init_locks(void);
34
35static void 34static void
36OPENSSL_init_crypto_internal(void) 35OPENSSL_init_crypto_internal(void)
37{ 36{
38 crypto_init_thread = pthread_self(); 37 crypto_init_thread = pthread_self();
38
39 OPENSSL_cpuid_setup(); 39 OPENSSL_cpuid_setup();
40 ERR_load_crypto_strings(); 40 ERR_load_crypto_strings();
41 OpenSSL_add_all_ciphers(); 41 OpenSSL_add_all_ciphers();
42 OpenSSL_add_all_digests(); 42 OpenSSL_add_all_digests();
43 crypto_init_locks();
44} 43}
45 44
46int 45int