Skip to content

Commit

Permalink
rand: don't free an mis-set pointer on error
Browse files Browse the repository at this point in the history
This is adding robustness to the code.  The fix to not mis-set the pointer
is in #16636.

Fixes #16631

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from #16640)

(cherry picked from commit caf569a)
  • Loading branch information
paulidale committed Sep 22, 2021
1 parent c9fb4c8 commit 7260376
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions providers/implementations/rands/drbg.c
Expand Up @@ -459,18 +459,18 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,

if (!drbg->instantiate(drbg, entropy, entropylen, nonce, noncelen,
pers, perslen)) {
cleanup_entropy(drbg, entropy, entropylen);
ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_INSTANTIATING_DRBG);
goto end;
}
cleanup_entropy(drbg, entropy, entropylen);

drbg->state = EVP_RAND_STATE_READY;
drbg->generate_counter = 1;
drbg->reseed_time = time(NULL);
tsan_store(&drbg->reseed_counter, drbg->reseed_next_counter);

end:
if (entropy != NULL)
cleanup_entropy(drbg, entropy, entropylen);
if (nonce != NULL)
ossl_prov_cleanup_nonce(drbg->provctx, nonce, noncelen);
if (drbg->state == EVP_RAND_STATE_READY)
Expand Down

0 comments on commit 7260376

Please sign in to comment.