summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2001-09-10 09:50:30 +0000
committerBodo Möller <bodo@openssl.org>2001-09-10 09:50:30 +0000
commit384eff877c53a9e800452cb8bd56bd81327f52f3 (patch)
treeceb7ada9430fbb4dfd87d706843f4e1443353b10
parent68dbba98170c858dc9e2316ba95fdef82f33f843 (diff)
Fix apps/openssl.c and ssl/ssltest.c so that they use
CRYPTO_set_mem_debug_options() instead of CRYPTO_dbg_set_options(), which is the default implementation of the former and should usually not be directly used by applications (at least if we assume that the options accepted by the default implementation will also be meaningful to any other implementations). Also fix apps/openssl.c and ssl/ssltest such that environment variable setting 'OPENSSL_DEBUG_MEMORY=off' actively disables the compiled-in library defaults (i.e. such that CRYPTO_MDEBUG is ignored in this case).
-rw-r--r--apps/openssl.c9
-rw-r--r--crypto/crypto.h13
-rw-r--r--ssl/ssltest.c7
3 files changed, 21 insertions, 8 deletions
diff --git a/apps/openssl.c b/apps/openssl.c
index f8d4ac69d6..9a5e37eac7 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -227,12 +227,17 @@ int main(int Argc, char *Argv[])
arg.data=NULL;
arg.count=0;
- if (getenv("OPENSSL_DEBUG_MEMORY") != NULL)
+ if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compiled-in library defaults */
{
if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))
{
CRYPTO_malloc_debug_init();
- CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
+ CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
+ }
+ else
+ {
+ /* OPENSSL_DEBUG_MEMORY=off */
+ CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
}
}
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
diff --git a/crypto/crypto.h b/crypto/crypto.h
index 9a642ab962..fc6ff860af 100644
--- a/crypto/crypto.h
+++ b/crypto/crypto.h
@@ -391,6 +391,9 @@ int CRYPTO_push_info_(const char *info, const char *file, int line);
int CRYPTO_pop_info(void);
int CRYPTO_remove_all_info(void);
+
+/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
+ * used as default in CRYPTO_MDEBUG compilations): */
/* The last argument has the following significance:
*
* 0: called before the actual memory allocation has taken place
@@ -399,18 +402,18 @@ int CRYPTO_remove_all_info(void);
void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
void CRYPTO_dbg_free(void *addr,int before_p);
-
/* Tell the debugging code about options. By default, the following values
* apply:
*
- * 0: Clear all options.
- * 1: Set the "Show Time" option.
- * 2: Set the "Show Thread Number" option.
- * 3: 1 + 2
+ * 0: Clear all options.
+ * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
+ * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
+ * V_CRYPTO_MDEBUG_ALL (3): 1 + 2
*/
void CRYPTO_dbg_set_options(long bits);
long CRYPTO_dbg_get_options(void);
+
#ifndef OPENSSL_NO_FP_API
void CRYPTO_mem_leaks_fp(FILE *);
#endif
diff --git a/ssl/ssltest.c b/ssl/ssltest.c
index 9ba560701c..0592e6c2a8 100644
--- a/ssl/ssltest.c
+++ b/ssl/ssltest.c
@@ -366,7 +366,12 @@ int main(int argc, char *argv[])
if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
{
CRYPTO_malloc_debug_init();
- CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
+ CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
+ }
+ else
+ {
+ /* OPENSSL_DEBUG_MEMORY=off */
+ CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
}
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);