diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-10-30 21:02:22 +0100 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-11-05 22:46:20 +0100 |
commit | fd59e425a865f306f3745f576f8b7b7a40dbbfcf (patch) | |
tree | 5ff342c21606a76ead75da39226233b7c77951e7 /test/drbgtest.c | |
parent | ee5a79104c4f7f59343a7b75815be3979a0f6b83 (diff) |
Fix error handling in drbgtest.c
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/7519)
Diffstat (limited to 'test/drbgtest.c')
-rw-r--r-- | test/drbgtest.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/drbgtest.c b/test/drbgtest.c index b4453b075e..371f138c7b 100644 --- a/test/drbgtest.c +++ b/test/drbgtest.c @@ -790,12 +790,15 @@ static void run_multi_thread_test(void) { unsigned char buf[256]; time_t start = time(NULL); - RAND_DRBG *public, *private; + RAND_DRBG *public = NULL, *private = NULL; - public = RAND_DRBG_get0_public(); - private = RAND_DRBG_get0_private(); - RAND_DRBG_set_reseed_time_interval(public, 1); + if (!TEST_ptr(public = RAND_DRBG_get0_public()) + || !TEST_ptr(private = RAND_DRBG_get0_private())) { + multi_thread_rand_bytes_succeeded = 0; + return; + } RAND_DRBG_set_reseed_time_interval(private, 1); + RAND_DRBG_set_reseed_time_interval(public, 1); do { if (RAND_bytes(buf, sizeof(buf)) <= 0) @@ -927,13 +930,16 @@ static size_t rand_drbg_seedlen(RAND_DRBG *drbg) */ static int test_rand_seed(void) { - RAND_DRBG *master = RAND_DRBG_get0_master(); + RAND_DRBG *master = NULL; unsigned char rand_buf[256]; size_t rand_buflen; -#ifdef OPENSSL_RAND_SEED_NONE - size_t required_seed_buflen = rand_drbg_seedlen(master); -#else size_t required_seed_buflen = 0; + + if (!TEST_ptr(master = RAND_DRBG_get0_master())) + return 0; + +#ifdef OPENSSL_RAND_SEED_NONE + required_seed_buflen = rand_drbg_seedlen(master); #endif memset(rand_buf, 0xCD, sizeof(rand_buf)); |