Fix spurious bntest failures.
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:31:45 +0000 (16:31 +0200)
BN_bntest_rand generates a single-word zero BIGNUM with quite a large probability.

A zero BIGNUM in turn will end up having a NULL |d|-buffer, which we shouldn't dereference without checking.

Reviewed-by: Richard Levitte <levitte@openssl.org>
test/bntest.c

index cf4d2ab3a65728a1e81566c571b5f8985a0636bf..430d2a02b81cbf7fae917f361d6eb8456eddf462 100644 (file)
@@ -526,9 +526,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);