aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif_api_funcs.h
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-10-05 11:52:52 +0200
committerSverker Eriksson <[email protected]>2012-10-09 22:05:11 +0200
commite5c1d346e29e5b1227ed30ee4d725a09eca0e532 (patch)
treeb5c8114a810459e855d4a81ec918c40e240c82d9 /erts/emulator/beam/erl_nif_api_funcs.h
parent54e7cc9086908a0e5642caa6ac3680557acc5a67 (diff)
downloadotp-e5c1d346e29e5b1227ed30ee4d725a09eca0e532.tar.gz
otp-e5c1d346e29e5b1227ed30ee4d725a09eca0e532.tar.bz2
otp-e5c1d346e29e5b1227ed30ee4d725a09eca0e532.zip
crypto: Make unloading of crypto safer
Facts: crypto nif-lib registers callback functions that openssl uses for memory management and thread synchronization. The callback functions can only be set once, openssl does not allow changing the callback functions. Problem: If openssl is dynamicly linked to crypto, you might get s scenario where the crypto lib is unloaded while leaving openssl loaded with its old pointers to the unloaded crypto code intact. If crypto is then reloaded (by init:restart() for example), the crypto nif-lib might get relocated at a different address. crypto calls openssl which in turn calls the old invalid callback functions...kaboom. Solution: Break apart the callback functions into a separate dynamic lib that crypto loads with dlopen. When crypto is unloaded the callback lib is left in place to be reused if/when crypto is loaded again.
Diffstat (limited to 'erts/emulator/beam/erl_nif_api_funcs.h')
-rw-r--r--erts/emulator/beam/erl_nif_api_funcs.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif_api_funcs.h b/erts/emulator/beam/erl_nif_api_funcs.h
index 6396af09d0..51ff1eaa48 100644
--- a/erts/emulator/beam/erl_nif_api_funcs.h
+++ b/erts/emulator/beam/erl_nif_api_funcs.h
@@ -138,6 +138,8 @@ ERL_NIF_API_FUNC_DECL(ERL_NIF_TERM,enif_make_uint64,(ErlNifEnv*, ErlNifUInt64));
ERL_NIF_API_FUNC_DECL(int,enif_is_exception,(ErlNifEnv*, ERL_NIF_TERM term));
ERL_NIF_API_FUNC_DECL(int,enif_make_reverse_list,(ErlNifEnv*, ERL_NIF_TERM term, ERL_NIF_TERM *list));
ERL_NIF_API_FUNC_DECL(int,enif_is_number,(ErlNifEnv*, ERL_NIF_TERM term));
+ERL_NIF_API_FUNC_DECL(void*,enif_dlopen,(const char* lib, void (*err_handler)(void*,const char*), void* err_arg));
+ERL_NIF_API_FUNC_DECL(void*,enif_dlsym,(void* handle, const char* symbol, void (*err_handler)(void*,const char*), void* err_arg));
/*
** Add new entries here to keep compatibility on Windows!!!
@@ -260,6 +262,8 @@ ERL_NIF_API_FUNC_DECL(int,enif_is_number,(ErlNifEnv*, ERL_NIF_TERM term));
# define enif_is_exception ERL_NIF_API_FUNC_MACRO(enif_is_exception)
# define enif_make_reverse_list ERL_NIF_API_FUNC_MACRO(enif_make_reverse_list)
# define enif_is_number ERL_NIF_API_FUNC_MACRO(enif_is_number)
+# define enif_dlopen ERL_NIF_API_FUNC_MACRO(enif_dlopen)
+# define enif_dlsym ERL_NIF_API_FUNC_MACRO(enif_dlsym)
/*
** Add new entries here