diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2008-06-04 00:50:24 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2008-06-04 00:50:24 +0000 |
commit | 1a4158bb8e92781f2de807dbf963b8909de8f693 (patch) | |
tree | eccbe24d478e3b2acd16b33f61a4c697ec1b1378 /sys/dev/rnd.c | |
parent | 571e5835f8796a3b8d5f4fc494cb6f26789eba8d (diff) |
fix math screwup that reintroduced a bias for upper_bounds in range
(2^30,2^31). Nothing in the tree yet requests random numbers bounded
by this range.
report jakob!deraadt; ok deraadt@
Diffstat (limited to 'sys/dev/rnd.c')
-rw-r--r-- | sys/dev/rnd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 60df674f0aa..c2692c62305 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.87 2008/03/02 21:29:07 djm Exp $ */ +/* $OpenBSD: rnd.c,v 1.88 2008/06/04 00:50:23 djm Exp $ */ /* * rnd.c -- A strong random number generator @@ -626,7 +626,7 @@ arc4random_uniform(u_int32_t upper_bound) min = 1 + ~upper_bound; /* 2**32 - upper_bound */ else { /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ - min = ((0xffffffff - (upper_bound << 2)) + 1) % upper_bound; + min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound; } #endif |