summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2021-09-20 16:35:10 +0200
committerDmitry Belyavskiy <beldmit@gmail.com>2021-09-21 18:43:10 +0200
commitc84f7c4c22828574885916479885ede6b32ba473 (patch)
tree16f3629da1ba116086b8be4f8c24d21c9a4df50e /providers
parent5a05c0d05233051f7af736e4f906b99f42212526 (diff)
Avoid double-free on unsuccessful getting PRNG seeding
Fixes #16631 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16636) (cherry picked from commit 52dcc011191ad1a40fd52ae92ef009309deaca52)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/rands/seed_src.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/providers/implementations/rands/seed_src.c b/providers/implementations/rands/seed_src.c
index 173c99ce17..7a4b780bb4 100644
--- a/providers/implementations/rands/seed_src.c
+++ b/providers/implementations/rands/seed_src.c
@@ -201,10 +201,11 @@ static size_t seed_get_seed(void *vseed, unsigned char **pout,
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
return 0;
}
- *pout = p;
if (seed_src_generate(vseed, p, bytes_needed, 0, prediction_resistance,
- adin, adin_len) != 0)
+ adin, adin_len) != 0) {
+ *pout = p;
return bytes_needed;
+ }
OPENSSL_secure_clear_free(p, bytes_needed);
return 0;
}