mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
Isolate dmalloc/openssl bridge code to crypto.c
This makes it so main.c, and the rest of src/or, no longer need to include any openssl headers.
This commit is contained in:
parent
04f1ddaa2a
commit
e7506c03cf
@ -3459,3 +3459,15 @@ crypto_global_cleanup(void)
|
|||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
#ifdef USE_DMALLOC
|
||||||
|
/** Tell the crypto library to use Tor's allocation functions rather than
|
||||||
|
* calling libc's allocation functions directly. Return 0 on success, -1
|
||||||
|
* on failure. */
|
||||||
|
int
|
||||||
|
crypto_use_tor_alloc_functions(void)
|
||||||
|
{
|
||||||
|
int r = CRYPTO_set_mem_ex_functions(tor_malloc_, tor_realloc_, tor_free_);
|
||||||
|
return r ? 0 : -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -131,6 +131,10 @@ int crypto_early_init(void) ATTR_WUR;
|
|||||||
int crypto_global_init(int hardwareAccel,
|
int crypto_global_init(int hardwareAccel,
|
||||||
const char *accelName,
|
const char *accelName,
|
||||||
const char *accelPath) ATTR_WUR;
|
const char *accelPath) ATTR_WUR;
|
||||||
|
#ifdef USE_DMALLOC
|
||||||
|
int crypto_use_tor_alloc_functions(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
void crypto_thread_cleanup(void);
|
void crypto_thread_cleanup(void);
|
||||||
int crypto_global_cleanup(void);
|
int crypto_global_cleanup(void);
|
||||||
|
|
||||||
|
@ -104,7 +104,6 @@
|
|||||||
#include "ext_orport.h"
|
#include "ext_orport.h"
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
#include <dmalloc.h>
|
#include <dmalloc.h>
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include "memarea.h"
|
#include "memarea.h"
|
||||||
#include "sandbox.h"
|
#include "sandbox.h"
|
||||||
@ -3617,8 +3616,8 @@ tor_main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
/* Instruct OpenSSL to use our internal wrappers for malloc,
|
/* Instruct OpenSSL to use our internal wrappers for malloc,
|
||||||
realloc and free. */
|
realloc and free. */
|
||||||
int r = CRYPTO_set_mem_ex_functions(tor_malloc_, tor_realloc_, tor_free_);
|
int r = crypto_use_tor_alloc_functions();
|
||||||
tor_assert(r);
|
tor_assert(r == 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef NT_SERVICE
|
#ifdef NT_SERVICE
|
||||||
|
@ -38,7 +38,6 @@ const char tor_git_revision[] = "";
|
|||||||
|
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
#include <dmalloc.h>
|
#include <dmalloc.h>
|
||||||
#include <openssl/crypto.h>
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -238,8 +237,8 @@ main(int c, const char **v)
|
|||||||
|
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
{
|
{
|
||||||
int r = CRYPTO_set_mem_ex_functions(tor_malloc_, tor_realloc_, tor_free_);
|
int r = crypto_use_tor_alloc_functions();
|
||||||
tor_assert(r);
|
tor_assert(r == 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user