diff options
author | delphij <delphij@FreeBSD.org> | 2015-07-15 19:21:26 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-07-15 19:21:26 +0000 |
commit | 2a25cee78ab1d37e7d2bc40ae675646974d99f56 (patch) | |
tree | b0302ac4be59e104f4e1e54014561a1389397192 /contrib/ntp/include/ssl_applink.c | |
parent | a0741a75537b2e0514472ac3b28afc55a7846c30 (diff) | |
download | FreeBSD-src-2a25cee78ab1d37e7d2bc40ae675646974d99f56.zip FreeBSD-src-2a25cee78ab1d37e7d2bc40ae675646974d99f56.tar.gz |
MFC r280849,280915-280916,281015-281016,282097,282408,282415,283542,
284864,285169-285170,285435:
ntp 4.2.8p3.
Relnotes: yes
Approved by: re (?)
Diffstat (limited to 'contrib/ntp/include/ssl_applink.c')
-rw-r--r-- | contrib/ntp/include/ssl_applink.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/contrib/ntp/include/ssl_applink.c b/contrib/ntp/include/ssl_applink.c new file mode 100644 index 0000000..ba1f4a8 --- /dev/null +++ b/contrib/ntp/include/ssl_applink.c @@ -0,0 +1,74 @@ +/* + * include/ssl_applink.c -- common NTP code for openssl/applink.c + * + * Each program which uses OpenSSL should include this file in _one_ + * of its source files and call ssl_applink() before any OpenSSL + * functions. + */ + +#if defined(OPENSSL) && defined(SYS_WINNT) +# ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4152) +# endif +# include <openssl/applink.c> +# ifdef _MSC_VER +# pragma warning(pop) +# endif +#endif + +#if defined(OPENSSL) && defined(_MSC_VER) && defined(_DEBUG) +#define WRAP_DBG_MALLOC +#endif + +#ifdef WRAP_DBG_MALLOC +void *wrap_dbg_malloc(size_t s, const char *f, int l); +void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l); +void wrap_dbg_free(void *p); +#endif + + +#if defined(OPENSSL) && defined(SYS_WINNT) +void ssl_applink(void); + +void +ssl_applink(void) +{ +#ifdef WRAP_DBG_MALLOC + CRYPTO_set_mem_ex_functions(wrap_dbg_malloc, wrap_dbg_realloc, wrap_dbg_free); +#else + CRYPTO_malloc_init(); +#endif +} +#else /* !OPENSSL || !SYS_WINNT */ +#define ssl_applink() do {} while (0) +#endif + + +#ifdef WRAP_DBG_MALLOC +/* + * OpenSSL malloc overriding uses different parameters + * for DEBUG malloc/realloc/free (lacking block type). + * Simple wrappers convert. + */ +void *wrap_dbg_malloc(size_t s, const char *f, int l) +{ + void *ret; + + ret = _malloc_dbg(s, _NORMAL_BLOCK, f, l); + return ret; +} + +void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l) +{ + void *ret; + + ret = _realloc_dbg(p, s, _NORMAL_BLOCK, f, l); + return ret; +} + +void wrap_dbg_free(void *p) +{ + _free_dbg(p, _NORMAL_BLOCK); +} +#endif /* WRAP_DBG_MALLOC */ |