Fix error handling in RAND_DRBG_set
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 29 Oct 2018 12:48:53 +0000 (13:48 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 5 Nov 2018 21:35:09 +0000 (22:35 +0100)
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7517)

crypto/rand/drbg_lib.c

index 8e372e593eed6b008c7d8f881809a483038edfea..f518ce51388b09c53798363c67891780f95d3b86 100644 (file)
@@ -180,12 +180,17 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags)
         else
             ret = drbg_hash_init(drbg);
     } else {
+        drbg->type = 0;
+        drbg->flags = 0;
+        drbg->meth = NULL;
         RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_UNSUPPORTED_DRBG_TYPE);
         return 0;
     }
 
-    if (ret == 0)
+    if (ret == 0) {
+        drbg->state = DRBG_ERROR;
         RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_ERROR_INITIALISING_DRBG);
+    }
     return ret;
 }