openssl/0030-tmp-Fix-rng-seed-double-free.patch
Dmitry Belyavskiy 3edf474b5d Avoid double-free on error seeding the RNG.
Resolves: rhbz#1952844
2021-09-20 17:13:26 +02:00

19 lines
723 B
Diff

diff --git a/providers/implementations/rands/seed_src.c b/providers/implementations/rands/seed_src.c
index 173c99ce1732..7a4b780bb469 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;
}