From: Geoff Thorpe Date: Tue, 2 Dec 2003 03:16:56 +0000 (+0000) Subject: BN_FLG_FREE is of extremely dubious usefulness, and is only referred to X-Git-Tag: BEN_FIPS_TEST_5~13^2~24 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2ae1ea3788206c8f79bc9f4d29eac56352bf3ff6;p=oweals%2Fopenssl.git BN_FLG_FREE is of extremely dubious usefulness, and is only referred to once in the source (where it is set for the benefit of no other code whatsoever). I've deprecated the declaration in the header and likewise made the use of the flag conditional in bn_lib.c. Note, this change also NULLs the 'd' pointer in a BIGNUM when it is reset but not deallocated. --- diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index 5346a353ab..f58d5f55a0 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -254,7 +254,9 @@ extern "C" { #define BN_FLG_MALLOCED 0x01 #define BN_FLG_STATIC_DATA 0x02 +#ifndef OPENSSL_NO_DEPRECATED #define BN_FLG_FREE 0x8000 /* used for debuging */ +#endif #define BN_set_flags(b,n) ((b)->flags|=(n)) #define BN_get_flags(b,n) ((b)->flags&(n)) diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index 3ecf83ddf2..3bc67f9de2 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -278,9 +278,15 @@ void BN_free(BIGNUM *a) if (a == NULL) return; if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA))) OPENSSL_free(a->d); - a->flags|=BN_FLG_FREE; /* REMOVE? */ if (a->flags & BN_FLG_MALLOCED) OPENSSL_free(a); + else + { +#ifndef OPENSSL_NO_DEPRECATED + a->flags|=BN_FLG_FREE; +#endif + a->d = NULL; + } } void BN_init(BIGNUM *a)