Make OPENSSL_malloc_init() a no-op
authorMatt Caswell <matt@openssl.org>
Tue, 5 Feb 2019 14:25:18 +0000 (14:25 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 7 Feb 2019 14:21:23 +0000 (14:21 +0000)
Making this a no-op removes a potential infinite loop than can occur in
some situations.

Fixes #2865

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8167)

doc/man3/OPENSSL_malloc.pod
include/openssl/crypto.h

index e17ff633b50cdadb16d45190903b77d570891aa7..f1de27a19c5f59f3fc163127aa1d2029411ff674 100644 (file)
@@ -90,10 +90,8 @@ generally macro's that add the standard C B<__FILE__> and B<__LINE__>
 parameters and call a lower-level B<CRYPTO_xxx> API.
 Some functions do not add those parameters, but exist for consistency.
 
-OPENSSL_malloc_init() sets the lower-level memory allocation functions
-to their default implementation.
-It is generally not necessary to call this, except perhaps in certain
-shared-library situations.
+OPENSSL_malloc_init() does nothing and does not need to be called. It is
+included for compatibility with older versions of OpenSSL.
 
 OPENSSL_malloc(), OPENSSL_realloc(), and OPENSSL_free() are like the
 C malloc(), realloc(), and free() functions.
index f9123021170526e07e861a60dc72e0fda2d45d51..cbde3d5ef1b7d670c8f4d3445ba26c802a75a95b 100644 (file)
@@ -109,13 +109,8 @@ DEFINE_STACK_OF(void)
 # define CRYPTO_EX_INDEX_DRBG            15
 # define CRYPTO_EX_INDEX__COUNT          16
 
-/*
- * This is the default callbacks, but we can have others as well: this is
- * needed in Win32 where the application malloc and the library malloc may
- * not be the same.
- */
-#define OPENSSL_malloc_init() \
-    CRYPTO_set_mem_functions(CRYPTO_malloc, CRYPTO_realloc, CRYPTO_free)
+/* No longer needed, so this is a no-op */
+#define OPENSSL_malloc_init() while(0) continue
 
 int CRYPTO_mem_ctrl(int mode);