From: Juergen Perlinger Date: Sun, 2 Jul 2017 07:16:39 +0000 (+0200) Subject: [Bug 3404] Fix openSSL DLL usage under Windows X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=636e0685d2bf7494e2b423402bac2f1a38a5a40e;p=thirdparty%2Fntp.git [Bug 3404] Fix openSSL DLL usage under Windows bk: 59589dd7NvBGPl2NK7u68Ohgu3Fzww --- diff --git a/ChangeLog b/ChangeLog index a1a1cfae4..65a2e4b4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- +* [Bug 3404] Fix openSSL DLL usage under Windows + - fix/drop assumptions on OpenSSL libs directory layout + --- (4.2.8p10-win-beta1) 2017/03/21 Released by Harlan Stenn (4.2.8p10) diff --git a/include/ssl_applink.c b/include/ssl_applink.c index e57cabdb5..86746f40d 100644 --- a/include/ssl_applink.c +++ b/include/ssl_applink.c @@ -14,9 +14,7 @@ # include "msvc_ssl_autolib.h" # endif # endif -# if OPENSSL_VERSION_NUMBER < 0x10100000L -# include -# endif +# include # ifdef _MSC_VER # pragma warning(pop) # endif @@ -27,10 +25,10 @@ #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); -void wrap_dbg_free_ex(void *p, const char *f, int l); +static void *wrap_dbg_malloc(size_t s, const char *f, int l); +static void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l); +static void wrap_dbg_free(void *p); +static void wrap_dbg_free_ex(void *p, const char *f, int l); #endif @@ -42,17 +40,21 @@ void ssl_applink(void) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L + # ifdef WRAP_DBG_MALLOC CRYPTO_set_mem_functions(wrap_dbg_malloc, wrap_dbg_realloc, wrap_dbg_free_ex); # else OPENSSL_malloc_init(); # endif -#else + +# else + # ifdef WRAP_DBG_MALLOC CRYPTO_set_mem_ex_functions(wrap_dbg_malloc, wrap_dbg_realloc, wrap_dbg_free); # else CRYPTO_malloc_init(); # endif + #endif /* OpenSSL version cascade */ } #else /* !OPENSSL || !SYS_WINNT */ @@ -66,7 +68,7 @@ ssl_applink(void) * for DEBUG malloc/realloc/free (lacking block type). * Simple wrappers convert. */ -void *wrap_dbg_malloc(size_t s, const char *f, int l) +static void *wrap_dbg_malloc(size_t s, const char *f, int l) { void *ret; @@ -74,7 +76,7 @@ void *wrap_dbg_malloc(size_t s, const char *f, int l) return ret; } -void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l) +static void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l) { void *ret; @@ -82,12 +84,12 @@ void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l) return ret; } -void wrap_dbg_free(void *p) +static void wrap_dbg_free(void *p) { _free_dbg(p, _NORMAL_BLOCK); } -void wrap_dbg_free_ex(void *p, const char *f, int l) +static void wrap_dbg_free_ex(void *p, const char *f, int l) { (void)f; (void)l; diff --git a/ports/winnt/include/msvc_ssl_autolib.h b/ports/winnt/include/msvc_ssl_autolib.h index 688b5e262..9a8ae6126 100644 --- a/ports/winnt/include/msvc_ssl_autolib.h +++ b/ports/winnt/include/msvc_ssl_autolib.h @@ -14,13 +14,13 @@ * So instead of manipulating the build environment we use the build * tools themselves to create requests for linking the right library. * - * To use this feature, it is recommended to use the precompiled - * VC binaries from Shining Light Productions: + * Unless you compile OpenSSL on your own, using the precompiled + * VC binaries from Shining Light Productions is probably easiest: * https://slproweb.com/products/Win32OpenSSL.html - * These are installed in (OPENSSL_LIB)/vc. * - * As an alternative, create the set of build variants of OpenSSL you - * need, implementing the following naming scheme: + * If 'OPENSSL_AUTOLINK_STRICT' is defined, then target bit width, + * runtime model and debug/release info are incoded into the library + * file name, according to this scheme: * * basename.lib * @@ -32,11 +32,16 @@ #pragma once #if !defined(_MSC_VER) + # error use this header only with Micro$oft Visual C compilers! + #elif defined(OPENSSL_NO_AUTOLINK) + # pragma message("automatic OpenSSL library selection disabled") -#else -/* ---------------------------------------------------------------- */ + +#elif defined(OPENSSL_AUTOLINK_STRICT) + + /* ---------------------------------------------------------------- */ /* selection dance to get the right libraries linked */ /* ---------------------------------------------------------------- */ @@ -85,10 +90,19 @@ * request in the object file, depending on the SSL version and the * build variant. */ + +# if OPENSSL_VERSION_NUMBER >= 0x10100000L +# pragma comment(lib, "libcrypto" LTAG_SIZE LTAG_RTLIB LTAG_DEBUG ".lib") +# else +# pragma comment(lib, "libeay32" LTAG_RTLIB LTAG_DEBUG ".lib") +# endif + +# else + # if OPENSSL_VERSION_NUMBER >= 0x10100000L -# pragma comment(lib, "libcrypto" LTAG_SIZE LTAG_RTLIB LTAG_DEBUG ".lib") +# pragma comment(lib, "libcrypto.lib") # else -# pragma comment(lib, "libeay32" LTAG_RTLIB LTAG_DEBUG ".lib") +# pragma comment(lib, "libeay32.lib") # endif #endif /*!defined(OPENSSL_NO_AUTOLINK)*/ diff --git a/ports/winnt/vs2008/debug-x64.vsprops b/ports/winnt/vs2008/debug-x64.vsprops index 3f241c2c8..36da166ea 100644 --- a/ports/winnt/vs2008/debug-x64.vsprops +++ b/ports/winnt/vs2008/debug-x64.vsprops @@ -14,7 +14,7 @@ /> diff --git a/ports/winnt/vs2008/debug.vsprops b/ports/winnt/vs2008/debug.vsprops index 0cbd9f4ae..2d3119e3e 100644 --- a/ports/winnt/vs2008/debug.vsprops +++ b/ports/winnt/vs2008/debug.vsprops @@ -14,7 +14,7 @@ /> diff --git a/ports/winnt/vs2008/release-x64.vsprops b/ports/winnt/vs2008/release-x64.vsprops index 8c0ee80b0..7639fbc7d 100644 --- a/ports/winnt/vs2008/release-x64.vsprops +++ b/ports/winnt/vs2008/release-x64.vsprops @@ -15,7 +15,7 @@ /> diff --git a/ports/winnt/vs2008/release.vsprops b/ports/winnt/vs2008/release.vsprops index 498779578..25c93f4c4 100644 --- a/ports/winnt/vs2008/release.vsprops +++ b/ports/winnt/vs2008/release.vsprops @@ -15,7 +15,7 @@ /> diff --git a/ports/winnt/vs2013/debug-x64.props b/ports/winnt/vs2013/debug-x64.props index 65d4f863f..1d3d52d9c 100644 --- a/ports/winnt/vs2013/debug-x64.props +++ b/ports/winnt/vs2013/debug-x64.props @@ -17,7 +17,7 @@ MachineX64 - $(OPENSSL64_LIB)\vc + $(OPENSSL64_LIB) diff --git a/ports/winnt/vs2013/debug.props b/ports/winnt/vs2013/debug.props index 46792f845..e82b7e896 100644 --- a/ports/winnt/vs2013/debug.props +++ b/ports/winnt/vs2013/debug.props @@ -17,7 +17,7 @@ MachineX86 - $(OPENSSL_LIB)\vc + $(OPENSSL_LIB) diff --git a/ports/winnt/vs2013/release-x64.props b/ports/winnt/vs2013/release-x64.props index 2bb07cb37..0122b1ee2 100644 --- a/ports/winnt/vs2013/release-x64.props +++ b/ports/winnt/vs2013/release-x64.props @@ -18,7 +18,7 @@ MachineX64 - $(OPENSSL64_LIB)\vc + $(OPENSSL64_LIB) diff --git a/ports/winnt/vs2013/release.props b/ports/winnt/vs2013/release.props index f6382dfba..0e8e2babd 100644 --- a/ports/winnt/vs2013/release.props +++ b/ports/winnt/vs2013/release.props @@ -18,7 +18,7 @@ MachineX86 - $(OPENSSL_LIB)\vc + $(OPENSSL_LIB) diff --git a/ports/winnt/vs2015/debug-x64.props b/ports/winnt/vs2015/debug-x64.props index 65d4f863f..1d3d52d9c 100644 --- a/ports/winnt/vs2015/debug-x64.props +++ b/ports/winnt/vs2015/debug-x64.props @@ -17,7 +17,7 @@ MachineX64 - $(OPENSSL64_LIB)\vc + $(OPENSSL64_LIB) diff --git a/ports/winnt/vs2015/debug.props b/ports/winnt/vs2015/debug.props index 46792f845..e82b7e896 100644 --- a/ports/winnt/vs2015/debug.props +++ b/ports/winnt/vs2015/debug.props @@ -17,7 +17,7 @@ MachineX86 - $(OPENSSL_LIB)\vc + $(OPENSSL_LIB) diff --git a/ports/winnt/vs2015/release-x64.props b/ports/winnt/vs2015/release-x64.props index 2bb07cb37..0122b1ee2 100644 --- a/ports/winnt/vs2015/release-x64.props +++ b/ports/winnt/vs2015/release-x64.props @@ -18,7 +18,7 @@ MachineX64 - $(OPENSSL64_LIB)\vc + $(OPENSSL64_LIB) diff --git a/ports/winnt/vs2015/release.props b/ports/winnt/vs2015/release.props index f6382dfba..0e8e2babd 100644 --- a/ports/winnt/vs2015/release.props +++ b/ports/winnt/vs2015/release.props @@ -18,7 +18,7 @@ MachineX86 - $(OPENSSL_LIB)\vc + $(OPENSSL_LIB)