diff options
author | 2008-06-04 00:50:23 +0000 | |
---|---|---|
committer | 2008-06-04 00:50:23 +0000 | |
commit | eef9a7c1a01adee2fb47f5dbb00afe811f6cb352 (patch) | |
tree | 11bbef6aaa122e0f0c74457e143edb937396c6d2 /lib/libc/crypt/arc4random.c | |
parent | fix some spacing issues; (diff) | |
download | wireguard-openbsd-eef9a7c1a01adee2fb47f5dbb00afe811f6cb352.tar.xz wireguard-openbsd-eef9a7c1a01adee2fb47f5dbb00afe811f6cb352.zip |
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 'lib/libc/crypt/arc4random.c')
-rw-r--r-- | lib/libc/crypt/arc4random.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/crypt/arc4random.c b/lib/libc/crypt/arc4random.c index bbe42bd204d..22b8d1f3c1b 100644 --- a/lib/libc/crypt/arc4random.c +++ b/lib/libc/crypt/arc4random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random.c,v 1.18 2008/03/16 19:47:43 otto Exp $ */ +/* $OpenBSD: arc4random.c,v 1.19 2008/06/04 00:50:23 djm Exp $ */ /* * Copyright (c) 1996, David Mazieres <dm@uun.org> @@ -231,7 +231,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 |