From f98a893ed454faf97d77a53833da95646478c14c Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 29 Oct 2018 13:48:53 +0100 Subject: [PATCH] Fix error handling in RAND_DRBG_set Reviewed-by: Matthias St. Pierre Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/7519) --- crypto/rand/drbg_lib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c index 43e7509e6a..b9c1cca0e0 100644 --- a/crypto/rand/drbg_lib.c +++ b/crypto/rand/drbg_lib.c @@ -115,6 +115,9 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags) switch (type) { default: + drbg->type = 0; + drbg->flags = 0; + drbg->meth = NULL; RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_UNSUPPORTED_DRBG_TYPE); return 0; case 0: @@ -127,8 +130,10 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags) break; } - if (ret == 0) + if (ret == 0) { + drbg->state = DRBG_ERROR; RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_ERROR_INITIALISING_DRBG); + } return ret; } -- 2.25.1