diff options
author | valdaarhun <icegambit91@gmail.com> | 2022-08-11 00:48:05 +0530 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-08-17 18:42:14 +0200 |
commit | 70f589ae41928edda18470ba1c3df82af02a92b3 (patch) | |
tree | bd1f423b035cdc927a7616c713e28909188b5d8d /crypto/bn | |
parent | 17b94de3df327e6619e52529e345a340d4a0a100 (diff) |
Fix memory leak in BN_rand_range()
The patch enables BN_rand_range() to exit immediately
if BIGNUM *rnd is NULL.
CLA: trivial
Fixes: #18951
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18982)
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_rand.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index 1b49596990..fd17e7a601 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -136,6 +136,11 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range, int n; int count = 100; + if (r == NULL) { + ERR_raise(ERR_LIB_BN, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + if (range->neg || BN_is_zero(range)) { ERR_raise(ERR_LIB_BN, BN_R_INVALID_RANGE); return 0; |