mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Per comments at the bottom of openssl/FAQ, call even more functions to
clean up OpenSSL's toys when it's done playing. (Why isn't there an OpenSSL_free_everything() function?) svn:r5321
This commit is contained in:
parent
b39d03116b
commit
9492424d3f
4 changed files with 16 additions and 0 deletions
|
@ -32,6 +32,7 @@ const char crypto_c_id[] = "$Id$";
|
||||||
#include <openssl/dh.h>
|
#include <openssl/dh.h>
|
||||||
#include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
#include <openssl/dh.h>
|
#include <openssl/dh.h>
|
||||||
|
#include <openssl/conf.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -220,16 +221,26 @@ crypto_global_init(int useAccel)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Free crypto resources held by this thread. */
|
||||||
|
void
|
||||||
|
crypto_thread_cleanup(void)
|
||||||
|
{
|
||||||
|
ERR_remove_state(0);
|
||||||
|
}
|
||||||
|
|
||||||
/** Uninitialize the crypto library. Return 0 on success, -1 on failure.
|
/** Uninitialize the crypto library. Return 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
crypto_global_cleanup(void)
|
crypto_global_cleanup(void)
|
||||||
{
|
{
|
||||||
EVP_cleanup();
|
EVP_cleanup();
|
||||||
|
//ERR_remove_state(0);
|
||||||
ERR_free_strings();
|
ERR_free_strings();
|
||||||
#ifndef NO_ENGINES
|
#ifndef NO_ENGINES
|
||||||
ENGINE_cleanup();
|
ENGINE_cleanup();
|
||||||
#endif
|
#endif
|
||||||
|
CONF_modules_unload(1);
|
||||||
|
CRYPTO_cleanup_all_ex_data();
|
||||||
#ifdef TOR_IS_MULTITHREADED
|
#ifdef TOR_IS_MULTITHREADED
|
||||||
if (_n_openssl_mutexes) {
|
if (_n_openssl_mutexes) {
|
||||||
int n = _n_openssl_mutexes;
|
int n = _n_openssl_mutexes;
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct crypto_dh_env_t crypto_dh_env_t;
|
||||||
|
|
||||||
/* global state */
|
/* global state */
|
||||||
int crypto_global_init(int hardwareAccel);
|
int crypto_global_init(int hardwareAccel);
|
||||||
|
void crypto_thread_cleanup(void);
|
||||||
int crypto_global_cleanup(void);
|
int crypto_global_cleanup(void);
|
||||||
|
|
||||||
/* environment setup */
|
/* environment setup */
|
||||||
|
|
|
@ -290,6 +290,7 @@ cpuworker_main(void *data)
|
||||||
if (last_onion_key)
|
if (last_onion_key)
|
||||||
crypto_free_pk_env(last_onion_key);
|
crypto_free_pk_env(last_onion_key);
|
||||||
tor_close_socket(fd);
|
tor_close_socket(fd);
|
||||||
|
crypto_thread_cleanup();
|
||||||
spawn_exit();
|
spawn_exit();
|
||||||
return 0; /* windows wants this function to return an int */
|
return 0; /* windows wants this function to return an int */
|
||||||
}
|
}
|
||||||
|
|
|
@ -793,12 +793,14 @@ dnsworker_main(void *data)
|
||||||
info(LD_EXIT,"(Error on %d was %s)", fd, tor_socket_strerror(tor_socket_errno(fd)));
|
info(LD_EXIT,"(Error on %d was %s)", fd, tor_socket_strerror(tor_socket_errno(fd)));
|
||||||
}
|
}
|
||||||
tor_close_socket(fd);
|
tor_close_socket(fd);
|
||||||
|
crypto_thread_cleanup();
|
||||||
spawn_exit();
|
spawn_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address_len && read_all(fd, address, address_len, 1) != address_len) {
|
if (address_len && read_all(fd, address, address_len, 1) != address_len) {
|
||||||
err(LD_BUG,"read hostname failed. Child exiting.");
|
err(LD_BUG,"read hostname failed. Child exiting.");
|
||||||
tor_close_socket(fd);
|
tor_close_socket(fd);
|
||||||
|
crypto_thread_cleanup();
|
||||||
spawn_exit();
|
spawn_exit();
|
||||||
}
|
}
|
||||||
address[address_len] = 0; /* null terminate it */
|
address[address_len] = 0; /* null terminate it */
|
||||||
|
@ -826,6 +828,7 @@ dnsworker_main(void *data)
|
||||||
if (write_all(fd, answer, 5, 1) != 5) {
|
if (write_all(fd, answer, 5, 1) != 5) {
|
||||||
err(LD_NET,"writing answer failed. Child exiting.");
|
err(LD_NET,"writing answer failed. Child exiting.");
|
||||||
tor_close_socket(fd);
|
tor_close_socket(fd);
|
||||||
|
crypto_thread_cleanup();
|
||||||
spawn_exit();
|
spawn_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue