diff options
author | Damien Miller <djm@mindrot.org> | 2008-06-04 10:54:00 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2008-06-04 10:54:00 +1000 |
commit | 58ea61ba2a747e4f0beb3afcbbdea8ada5119143 (patch) | |
tree | ec76bc8cd66c5c5b61fe7d3bf3c7ae99b6d2b758 /openbsd-compat | |
parent | a7058ec7c03017b89ba75fc0b9a58ca672aab9e9 (diff) | |
download | openssh-git-58ea61ba2a747e4f0beb3afcbbdea8ada5119143.tar.gz |
- (djm) [openbsd-compat/bsd-arc4random.c] Fix math bug that caused bias
in arc4random_uniform with upper_bound in (2^30,2*31). Note that
OpenSSH did not make requests with upper bounds in this range.
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/bsd-arc4random.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/openbsd-compat/bsd-arc4random.c b/openbsd-compat/bsd-arc4random.c index 92e7e7b5..9d4c8690 100644 --- a/openbsd-compat/bsd-arc4random.c +++ b/openbsd-compat/bsd-arc4random.c @@ -129,7 +129,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 |