]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: fix coverity 1414451: unchecked return value
authorPauli <ppzgs1@gmail.com>
Thu, 18 Mar 2021 23:14:40 +0000 (09:14 +1000)
committerPauli <pauli@openssl.org>
Thu, 25 Mar 2021 22:46:01 +0000 (08:46 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14615)

test/exptest.c

index a1ac44e909e1e61ce8a33ab600ef353df71b43ef..9474f21f3ba294c0dee33d4d26988e7ce144485f 100644 (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))