diff options
| author | jsing <> | 2023-01-07 16:17:29 +0000 |
|---|---|---|
| committer | jsing <> | 2023-01-07 16:17:29 +0000 |
| commit | 220d5e143ca958f5dcdb94de83982d26c17758d0 (patch) | |
| tree | ab972a1588a39e12a9b25e946d3436640b3d01c3 /src | |
| parent | cdfbcfee1342f6a121872deb4ffaad163f6f35ba (diff) | |
| download | openbsd-220d5e143ca958f5dcdb94de83982d26c17758d0.tar.gz openbsd-220d5e143ca958f5dcdb94de83982d26c17758d0.tar.bz2 openbsd-220d5e143ca958f5dcdb94de83982d26c17758d0.zip | |
Rewrite/simplify BN_free().
ok tb@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 70b6899a42..e8802300ce 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_lib.c,v 1.70 2023/01/07 16:13:46 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.71 2023/01/07 16:17:29 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -97,18 +97,20 @@ BN_clear(BIGNUM *a) | |||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void | 99 | void |
| 100 | BN_free(BIGNUM *a) | 100 | BN_free(BIGNUM *bn) |
| 101 | { | 101 | { |
| 102 | int i; | 102 | if (bn == NULL) |
| 103 | return; | ||
| 103 | 104 | ||
| 104 | if (a == NULL) | 105 | if (!BN_get_flags(bn, BN_FLG_STATIC_DATA)) |
| 106 | freezero(bn->d, bn->dmax * sizeof(bn->d[0])); | ||
| 107 | |||
| 108 | if (!BN_get_flags(bn, BN_FLG_MALLOCED)) { | ||
| 109 | explicit_bzero(bn, sizeof(*bn)); | ||
| 105 | return; | 110 | return; |
| 106 | if (a->d != NULL && !(BN_get_flags(a, BN_FLG_STATIC_DATA))) | 111 | } |
| 107 | freezero(a->d, a->dmax * sizeof(a->d[0])); | 112 | |
| 108 | i = BN_get_flags(a, BN_FLG_MALLOCED); | 113 | freezero(bn, sizeof(*bn)); |
| 109 | explicit_bzero(a, sizeof(BIGNUM)); | ||
| 110 | if (i) | ||
| 111 | free(a); | ||
| 112 | } | 114 | } |
| 113 | 115 | ||
| 114 | void | 116 | void |
