Skip to content

Commit

Permalink
Fix leak of a RAND_POOL in error condition
Browse files Browse the repository at this point in the history
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 openssl#26154)
  • Loading branch information
t8m committed Dec 13, 2024
1 parent a82c2bf commit c5257fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion providers/implementations/rands/seed_src.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
4 changes: 3 additions & 1 deletion providers/implementations/rands/seed_src_jitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit c5257fd

Please sign in to comment.