Fix statically linked engine initialization w/ fips
authorMatt Hauck <matt.hauck@tanium.com>
Wed, 13 Jul 2016 18:27:40 +0000 (11:27 -0700)
committerRichard Levitte <levitte@openssl.org>
Thu, 9 Feb 2017 22:39:40 +0000 (23:39 +0100)
This only manifested itself with FIPS enabled statically linked
engines. The OPENSSL_init call ended up invoking RAND_init_fips
for a FIPS enabled build, which called CRYPTO_malloc, resulting in
disallowing the engine to finish its IMPLEMENT_DYNAMIC_BIND_FN call.

(Merged from https://github.com/openssl/openssl/pull/1308)Reviewed-by: Geoff Thorpe <geoff@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
CLA: trivial
(Merged from https://github.com/openssl/openssl/pull/1308)

crypto/mem.c

index 06c3960cc6c05b2cf630aad503df8c4af2ee7ea3..dd4c9ce9e0b86b8727cbb86cb80c731ec6ea096f 100644 (file)
@@ -150,12 +150,12 @@ static long (*get_debug_options_func) (void) = NULL;
 int CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),
                              void (*f) (void *))
 {
-    /* Dummy call just to ensure OPENSSL_init() gets linked in */
-    OPENSSL_init();
     if (!allow_customize)
         return 0;
     if ((m == 0) || (r == 0) || (f == 0))
         return 0;
+    /* Dummy call just to ensure OPENSSL_init() gets linked in */
+    OPENSSL_init();
     malloc_func = m;
     malloc_ex_func = default_malloc_ex;
     realloc_func = r;