diff options
author | Sverker Eriksson <[email protected]> | 2018-05-18 14:13:21 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2018-05-18 14:13:21 +0200 |
commit | 329e9b36cccdf62b01dd3e9b28a2893654f2aa46 (patch) | |
tree | fd2867b4576056e7079b931b29f3198a82a87e64 /lib/crypto/c_src | |
parent | 2bc6ef5bb99ff1a7a4ac2a1370f0628acc730869 (diff) | |
parent | 93b48f41103a7491ae1c6955ff5ceb5ee15ee666 (diff) | |
download | otp-329e9b36cccdf62b01dd3e9b28a2893654f2aa46.tar.gz otp-329e9b36cccdf62b01dd3e9b28a2893654f2aa46.tar.bz2 otp-329e9b36cccdf62b01dd3e9b28a2893654f2aa46.zip |
Merge branch 'sverker/crypto-upgrade-bug/OTP-15088'
* sverker/crypto-upgrade-bug/OTP-15088:
crypto: Robustify the do-once-initialization
crypto: Fix upgrade bug when engine support is missing
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r-- | lib/crypto/c_src/crypto.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c index df4e2245f4..6e113ef39e 100644 --- a/lib/crypto/c_src/crypto.c +++ b/lib/crypto/c_src/crypto.c @@ -544,6 +544,7 @@ static int zero_terminate(ErlNifBinary bin, char **buf); #endif static int library_refc = 0; /* number of users of this dynamic library */ +static int library_initialized = 0; static ErlNifFunc nif_funcs[] = { {"info_lib", 0, info_lib}, @@ -1005,14 +1006,14 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info) PRINTF_ERR0("CRYPTO: Could not open resource type 'ENGINE_CTX'"); return __LINE__; } +#endif - if (library_refc > 0) { + if (library_initialized) { /* Repeated loading of this library (module upgrade). * Atoms and callbacks are already set, we are done. */ return 0; } -#endif atom_true = enif_make_atom(env,"true"); atom_false = enif_make_atom(env,"false"); @@ -1119,10 +1120,6 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info) atom_password = enif_make_atom(env,"password"); #endif - init_digest_types(env); - init_cipher_types(env); - init_algorithms_types(env); - #ifdef HAVE_DYNAMIC_CRYPTO_LIB { void* handle; @@ -1168,6 +1165,11 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info) } #endif /* OPENSSL_THREADS */ + init_digest_types(env); + init_cipher_types(env); + init_algorithms_types(env); + + library_initialized = 1; return 0; } |