test: fix coverity 1414451: unchecked return value

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14615)
This commit is contained in:
Pauli 2021-03-19 09:14:40 +10:00 committed by Pauli
parent a02d70dd51
commit 0d2b8bd261

View File

@ -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))