Avoid some memory holes, one of which was pointed out by
authorBodo Möller <bodo@openssl.org>
Fri, 25 Jun 1999 13:41:35 +0000 (13:41 +0000)
committerBodo Möller <bodo@openssl.org>
Fri, 25 Jun 1999 13:41:35 +0000 (13:41 +0000)
"Chad C. Mulligan" <mulligan@antipope.org>.

apps/openssl.c
crypto/dsa/dsa_gen.c
crypto/dsa/dsa_sign.c
crypto/dsa/dsatest.c

index 9a337fb316e745f3d98879138200752cd9e0d962..846d4af6b8771b5abf22a13d5b204cced8376b93 100644 (file)
@@ -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();
 
index 2b762d66f532a64d8c4e30ede12159ef87a74841..b5e5ec06e5e49750cc233b5b5580826a32af195d 100644 (file)
@@ -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);
        }
index 709d93ee73020f20e21b14927e978cf001785f43..774c161964312bfc477e167bb03fea281c8fc1c7 100644 (file)
@@ -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);
        }
 
index 38dd0c0c4dc8a0466b1c87c19e5ff38293a5d028..70aa8ca28defa046a4104a678244ffa64149a114 100644 (file)
@@ -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);
        }