From: Pauli Date: Thu, 18 Mar 2021 23:14:40 +0000 (+1000) Subject: test: fix coverity 1414451: unchecked return value X-Git-Tag: openssl-3.0.0-alpha14~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d2b8bd261bbebc8a1834d85ede0a2bd22c71851;p=thirdparty%2Fopenssl.git test: fix coverity 1414451: unchecked return value Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14615) --- diff --git a/test/exptest.c b/test/exptest.c index a1ac44e909e..9474f21f3ba 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))