summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c26
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lib.c26
2 files changed, 34 insertions, 18 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index a8022f6668..9787a31dbb 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -226,11 +226,22 @@ void BN_clear_free(BIGNUM *a)
226 free(a); 226 free(a);
227 } 227 }
228 228
229void 229void BN_free(BIGNUM *a)
230BN_free(BIGNUM *a) 230 {
231{ 231 if (a == NULL) return;
232 BN_clear_free(a); 232 bn_check_top(a);
233} 233 if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
234 free(a->d);
235 if (a->flags & BN_FLG_MALLOCED)
236 free(a);
237 else
238 {
239#ifndef OPENSSL_NO_DEPRECATED
240 a->flags|=BN_FLG_FREE;
241#endif
242 a->d = NULL;
243 }
244 }
234 245
235void BN_init(BIGNUM *a) 246void BN_init(BIGNUM *a)
236 { 247 {
@@ -389,10 +400,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
389 { 400 {
390 BN_ULONG *a = bn_expand_internal(b, words); 401 BN_ULONG *a = bn_expand_internal(b, words);
391 if(!a) return NULL; 402 if(!a) return NULL;
392 if(b->d) { 403 if(b->d) free(b->d);
393 OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));
394 free(b->d);
395 }
396 b->d=a; 404 b->d=a;
397 b->dmax=words; 405 b->dmax=words;
398 } 406 }
diff --git a/src/lib/libssl/src/crypto/bn/bn_lib.c b/src/lib/libssl/src/crypto/bn/bn_lib.c
index a8022f6668..9787a31dbb 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lib.c
+++ b/src/lib/libssl/src/crypto/bn/bn_lib.c
@@ -226,11 +226,22 @@ void BN_clear_free(BIGNUM *a)
226 free(a); 226 free(a);
227 } 227 }
228 228
229void 229void BN_free(BIGNUM *a)
230BN_free(BIGNUM *a) 230 {
231{ 231 if (a == NULL) return;
232 BN_clear_free(a); 232 bn_check_top(a);
233} 233 if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
234 free(a->d);
235 if (a->flags & BN_FLG_MALLOCED)
236 free(a);
237 else
238 {
239#ifndef OPENSSL_NO_DEPRECATED
240 a->flags|=BN_FLG_FREE;
241#endif
242 a->d = NULL;
243 }
244 }
234 245
235void BN_init(BIGNUM *a) 246void BN_init(BIGNUM *a)
236 { 247 {
@@ -389,10 +400,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
389 { 400 {
390 BN_ULONG *a = bn_expand_internal(b, words); 401 BN_ULONG *a = bn_expand_internal(b, words);
391 if(!a) return NULL; 402 if(!a) return NULL;
392 if(b->d) { 403 if(b->d) free(b->d);
393 OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));
394 free(b->d);
395 }
396 b->d=a; 404 b->d=a;
397 b->dmax=words; 405 b->dmax=words;
398 } 406 }