Просмотр исходного кода

* Cleanup libcrypto on exit as well

Bryan Drewery 15 лет назад
Родитель
Сommit
2c136155d8
3 измененных файлов с 8 добавлено и 0 удалено
  1. 5 0
      src/libcrypto.c
  2. 2 0
      src/libcrypto.h
  3. 1 0
      src/main.c

+ 5 - 0
src/libcrypto.c

@@ -81,6 +81,9 @@ static int load_symbols(void *handle) {
   DLSYM_GLOBAL(handle, DH_new);
   DLSYM_GLOBAL(handle, DH_size);
 
+  DLSYM_GLOBAL(handle, EVP_cleanup);
+  DLSYM_GLOBAL(handle, CRYPTO_cleanup_all_ex_data);
+
 
   return 0;
 }
@@ -116,6 +119,8 @@ int load_libcrypto() {
 int unload_libcrypto() {
   if (libcrypto_handle) {
     ERR_free_strings();
+    EVP_cleanup();
+    CRYPTO_cleanup_all_ex_data();
 
     // Cleanup symbol table
     for (size_t i = 0; i < my_symbols.length(); ++i) {

+ 2 - 0
src/libcrypto.h

@@ -65,6 +65,8 @@ typedef int (*DH_generate_key_t)(DH*);
 typedef DH* (*DH_new_t)(void);
 typedef int (*DH_size_t)(const DH*);
 
+typedef void (*EVP_cleanup_t)(void);
+typedef void (*CRYPTO_cleanup_all_ex_data_t)(void);
 
 int load_libcrypto();
 int unload_libcrypto();

+ 1 - 0
src/main.c

@@ -196,6 +196,7 @@ void fatal(const char *s, int recoverable)
     }
   }
 
+  unload_libcrypto();
 #ifdef EGG_SSL_EXT
   if (ssl_use) {
     unload_libssl();