bntest: don't dereference the |d| array for a zero BIGNUM.
authorEmilia Kasper <emilia@openssl.org>
Mon, 31 Aug 2015 11:57:44 +0000 (13:57 +0200)
committerEmilia Kasper <emilia@openssl.org>
Mon, 31 Aug 2015 14:53:37 +0000 (16:53 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 4d04226c2ec7e7f69f6234def63631648e35e828)
(cherry picked from commit 9c989aaa749d88b63bef5d5beeb3046eae62d836)

crypto/bn/bntest.c

index 06662c58b32f3c7eb22706a0d6effd80c97f1c73..9f888f90b068f6353da20d368c0bf84d5bf7ffec 100644 (file)
@@ -516,9 +516,9 @@ int test_div_word(BIO *bp)
         do {
             BN_bntest_rand(&a, 512, -1, 0);
             BN_bntest_rand(&b, BN_BITS2, -1, 0);
-            s = b.d[0];
-        } while (!s);
+        } while (BN_is_zero(&b));
 
+        s = b.d[0];
         BN_copy(&b, &a);
         r = BN_div_word(&b, s);