diff options
author | Matt Caswell <matt@openssl.org> | 2021-03-18 10:22:51 +0000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-03-20 10:26:00 +1000 |
commit | b402f00ee26157ad4e7e6e52f3a736743e3de46f (patch) | |
tree | ead2cbacb68a89fcf80e2d7a36364e3754015a78 /crypto/rand | |
parent | f9398cc2b31858ddaaea3f5cfec2fce7f9b90347 (diff) |
Add a missing RUN_ONCE in rand_lib.c
Some of the callbacks in rand_lib.c were being invoked without the
RUN_ONCE for that file being called. We add it during rand_pool_new
which should cover all cases.
Fixes #7870
Fixes #11144
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14603)
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/rand_lib.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index ba3a29e584..46e83d0741 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -432,9 +432,13 @@ err: RAND_POOL *rand_pool_new(int entropy_requested, int secure, size_t min_len, size_t max_len) { - RAND_POOL *pool = OPENSSL_zalloc(sizeof(*pool)); + RAND_POOL *pool; size_t min_alloc_size = RAND_POOL_MIN_ALLOCATION(secure); + if (!RUN_ONCE(&rand_init, do_rand_init)) + return NULL; + + pool = OPENSSL_zalloc(sizeof(*pool)); if (pool == NULL) { RANDerr(RAND_F_RAND_POOL_NEW, ERR_R_MALLOC_FAILURE); return NULL; |