Fix leak of a RAND_POOL in error condition

Fixes Coverity 1636676

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26154)
This commit is contained in:
Tomas Mraz 2024-12-11 16:34:25 +01:00
parent a82c2bf5c9
commit c5257fd8d0
2 changed files with 6 additions and 2 deletions

View File

@ -112,8 +112,10 @@ static int seed_src_generate(void *vseed, unsigned char *out, size_t outlen,
entropy_available = ossl_pool_acquire_entropy(pool);
if (entropy_available > 0) {
if (!ossl_rand_pool_adin_mix_in(pool, adin, adin_len))
if (!ossl_rand_pool_adin_mix_in(pool, adin, adin_len)) {
ossl_rand_pool_free(pool);
return 0;
}
memcpy(out, ossl_rand_pool_buffer(pool), ossl_rand_pool_length(pool));
}

View File

@ -198,8 +198,10 @@ static int jitter_generate(void *vseed, unsigned char *out, size_t outlen,
entropy_available = ossl_prov_acquire_entropy_from_jitter(s, pool);
if (entropy_available > 0) {
if (!ossl_rand_pool_adin_mix_in(pool, adin, adin_len))
if (!ossl_rand_pool_adin_mix_in(pool, adin, adin_len)) {
ossl_rand_pool_free(pool);
return 0;
}
memcpy(out, ossl_rand_pool_buffer(pool), ossl_rand_pool_length(pool));
}