aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/dsa/dsatest.c2
-rw-r--r--crypto/mem.c34
-rw-r--r--crypto/rsa/rsa_oaep_test.c2
3 files changed, 26 insertions, 12 deletions
diff --git a/crypto/dsa/dsatest.c b/crypto/dsa/dsatest.c
index 70aa8ca28d..fc25c9a1b7 100644
--- a/crypto/dsa/dsatest.c
+++ b/crypto/dsa/dsatest.c
@@ -134,7 +134,7 @@ int main(int argc, char **argv)
if (bio_err == NULL)
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
BIO_printf(bio_err,"test generation of DSA parameters\n");
BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n");
diff --git a/crypto/mem.c b/crypto/mem.c
index 01f189bfc9..8a74507716 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -63,11 +63,21 @@
#include <openssl/lhash.h>
#include "cryptlib.h"
-#ifdef CRYPTO_MDEBUG
-static int mh_mode=CRYPTO_MEM_CHECK_ON;
-#else
+/* #ifdef CRYPTO_MDEBUG */
+/* static int mh_mode=CRYPTO_MEM_CHECK_ON; */
+/* #else */
static int mh_mode=CRYPTO_MEM_CHECK_OFF;
-#endif
+/* #endif */
+/* State CRYPTO_MEM_CHECK_ON exists only temporarily when the library
+ * thinks that certain allocations should not be checked (e.g. the data
+ * structures used for memory checking). It is not suitable as an initial
+ * state: the library will unexpectedly enable memory checking when it
+ * executes one of those sections that want to disable checking
+ * temporarily.
+ *
+ * State CRYPTO_MEM_CHECK_ENABLE without ..._ON makes no sense whatsoever.
+ */
+
static unsigned long order=0;
static LHASH *mh=NULL;
@@ -88,19 +98,23 @@ int CRYPTO_mem_ctrl(int mode)
CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
switch (mode)
{
- case CRYPTO_MEM_CHECK_ON:
- mh_mode|=CRYPTO_MEM_CHECK_ON;
+ /* for applications: */
+ case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
+ mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;
break;
- case CRYPTO_MEM_CHECK_OFF:
- mh_mode&= ~CRYPTO_MEM_CHECK_ON;
+ case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */
+ mh_mode = 0;
break;
- case CRYPTO_MEM_CHECK_DISABLE:
+
+ /* switch off temporarily (for library-internal use): */
+ case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;
break;
- case CRYPTO_MEM_CHECK_ENABLE:
+ case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
if (mh_mode&CRYPTO_MEM_CHECK_ON)
mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
break;
+
default:
break;
}
diff --git a/crypto/rsa/rsa_oaep_test.c b/crypto/rsa/rsa_oaep_test.c
index 5931c65c2c..0d4e39d3da 100644
--- a/crypto/rsa/rsa_oaep_test.c
+++ b/crypto/rsa/rsa_oaep_test.c
@@ -216,7 +216,7 @@ int main()
int clen = 0;
int num;
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
plen = sizeof(ptext_ex) - 1;