summaryrefslogtreecommitdiff
path: root/test/drbgtest.c
diff options
context:
space:
mode:
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-04-17 08:07:11 +0200
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-04-17 17:24:50 +0200
commit43687d685ffd71fc1cf0ea1079f6d4958dff5026 (patch)
treef1ee2ba81682e92bb7eeb4bd495a86b23101482e /test/drbgtest.c
parent826e154481e93413a79c37cb1bf4da6175a05875 (diff)
downloadopenssl-new-43687d685ffd71fc1cf0ea1079f6d4958dff5026.tar.gz
DRBG: fix coverity issues
- drbg_lib.c: Silence coverity warning: the comment preceding the RAND_DRBG_instantiate() call explicitely states that the error is ignored and explains the reason why. - drbgtest: Add checks for the return values of RAND_bytes() and RAND_priv_bytes() to run_multi_thread_test(). Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5976)
Diffstat (limited to 'test/drbgtest.c')
-rw-r--r--test/drbgtest.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/drbgtest.c b/test/drbgtest.c
index 5426046854..d69456b4ee 100644
--- a/test/drbgtest.c
+++ b/test/drbgtest.c
@@ -783,6 +783,8 @@ error:
}
#if defined(OPENSSL_THREADS)
+static int multi_thread_rand_bytes_succeeded = 1;
+static int multi_thread_rand_priv_bytes_succeeded = 1;
static void run_multi_thread_test(void)
{
@@ -796,8 +798,10 @@ static void run_multi_thread_test(void)
RAND_DRBG_set_reseed_time_interval(private, 1);
do {
- RAND_bytes(buf, sizeof(buf));
- RAND_priv_bytes(buf, sizeof(buf));
+ if (RAND_bytes(buf, sizeof(buf)) <= 0)
+ multi_thread_rand_bytes_succeeded = 0;
+ if (RAND_priv_bytes(buf, sizeof(buf)) <= 0)
+ multi_thread_rand_priv_bytes_succeeded = 0;
}
while(time(NULL) - start < 5);
}
@@ -849,7 +853,7 @@ static int wait_for_thread(thread_t thread)
* The main thread will also run the test, so we'll have THREADS+1 parallel
* tests running
*/
-#define THREADS 3
+# define THREADS 3
static int test_multi_thread(void)
{
@@ -861,6 +865,12 @@ static int test_multi_thread(void)
run_multi_thread_test();
for (i = 0; i < THREADS; i++)
wait_for_thread(t[i]);
+
+ if (!TEST_true(multi_thread_rand_bytes_succeeded))
+ return 0;
+ if (!TEST_true(multi_thread_rand_priv_bytes_succeeded))
+ return 0;
+
return 1;
}
#endif