From 227cd06ffea642eb155449888a46159481afe0d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Fri, 25 Jun 1999 13:41:35 +0000 Subject: [PATCH] Avoid some memory holes, one of which was pointed out by "Chad C. Mulligan" . --- apps/openssl.c | 2 +- crypto/dsa/dsa_gen.c | 1 + crypto/dsa/dsa_sign.c | 2 ++ crypto/dsa/dsatest.c | 5 ++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/openssl.c b/apps/openssl.c index 9a337fb316..846d4af6b8 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -136,7 +136,7 @@ int main(int Argc, char *Argv[]) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); - CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); + CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE); ERR_load_crypto_strings(); diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 2b762d66f5..b5e5ec06e5 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -326,6 +326,7 @@ err: if (ok == -1) DSAerr(DSA_F_DSA_IS_PRIME,ERR_R_BN_LIB); BN_CTX_free(ctx); BN_CTX_free(ctx2); + BN_MONT_CTX_free(mont); return(ok); } diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c index 709d93ee73..774c161964 100644 --- a/crypto/dsa/dsa_sign.c +++ b/crypto/dsa/dsa_sign.c @@ -125,6 +125,8 @@ err: if (ctx != NULL) BN_CTX_free(ctx); BN_clear_free(&m); BN_clear_free(&xr); + if (kinv != NULL) /* dsa->kinv is NULL now if we used it */ + BN_clear_free(kinv); return(ret); } diff --git a/crypto/dsa/dsatest.c b/crypto/dsa/dsatest.c index 38dd0c0c4d..70aa8ca28d 100644 --- a/crypto/dsa/dsatest.c +++ b/crypto/dsa/dsatest.c @@ -134,6 +134,8 @@ 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); + BIO_printf(bio_err,"test generation of DSA parameters\n"); BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n"); dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb, @@ -190,8 +192,9 @@ int main(int argc, char **argv) end: if (!ret) ERR_print_errors(bio_err); - if (bio_err != NULL) BIO_free(bio_err); if (dsa != NULL) DSA_free(dsa); + CRYPTO_mem_leaks(bio_err); + if (bio_err != NULL) BIO_free(bio_err); exit(!ret); return(0); } -- 2.25.1