summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-19 09:14:40 +1000
committerPauli <pauli@openssl.org>2021-03-26 08:46:01 +1000
commit0d2b8bd261bbebc8a1834d85ede0a2bd22c71851 (patch)
tree3787b459e26b697fc9006f1f3186c190cf8b5518 /test
parenta02d70dd510e66eb2f916a723e30fd7e75b33eef (diff)
downloadopenssl-new-0d2b8bd261bbebc8a1834d85ede0a2bd22c71851.tar.gz
test: fix coverity 1414451: unchecked return value
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14615)
Diffstat (limited to 'test')
-rw-r--r--test/exptest.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/test/exptest.c b/test/exptest.c
index a1ac44e909..9474f21f3b 100644
--- a/test/exptest.c
+++ b/test/exptest.c
@@ -144,17 +144,26 @@ static int test_mod_exp(int round)
|| !TEST_ptr(m = BN_new()))
goto err;
- RAND_bytes(&c, 1);
+ if (!TEST_true(RAND_bytes(&c, 1)))
+ goto err;
c = (c % BN_BITS) - BN_BITS2;
- BN_rand(a, NUM_BITS + c, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY);
+ if (!TEST_true(BN_rand(a, NUM_BITS + c, BN_RAND_TOP_ONE,
+ BN_RAND_BOTTOM_ANY)))
+ goto err;
- RAND_bytes(&c, 1);
+ if (!TEST_true(RAND_bytes(&c, 1)))
+ goto err;
c = (c % BN_BITS) - BN_BITS2;
- BN_rand(b, NUM_BITS + c, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY);
+ if (!TEST_true(BN_rand(b, NUM_BITS + c, BN_RAND_TOP_ONE,
+ BN_RAND_BOTTOM_ANY)))
+ goto err;
- RAND_bytes(&c, 1);
+ if (!TEST_true(RAND_bytes(&c, 1)))
+ goto err;
c = (c % BN_BITS) - BN_BITS2;
- BN_rand(m, NUM_BITS + c, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD);
+ if (!TEST_true(BN_rand(m, NUM_BITS + c, BN_RAND_TOP_ONE,
+ BN_RAND_BOTTOM_ODD)))
+ goto err;
if (!TEST_true(BN_mod(a, a, m, ctx))
|| !TEST_true(BN_mod(b, b, m, ctx))