summaryrefslogtreecommitdiff
path: root/src/lib/libc/crypt
diff options
context:
space:
mode:
authordjm <>2008-06-04 00:50:23 +0000
committerdjm <>2008-06-04 00:50:23 +0000
commit9cb2819066edcb7bd907e9809cc6a87dbf7b3a71 (patch)
tree33d6ae3cde9860729a5a0c962f3df1738d705bb9 /src/lib/libc/crypt
parentf3b12bced646aded51b00b6567551d2da20238b8 (diff)
downloadopenbsd-9cb2819066edcb7bd907e9809cc6a87dbf7b3a71.tar.gz
openbsd-9cb2819066edcb7bd907e9809cc6a87dbf7b3a71.tar.bz2
openbsd-9cb2819066edcb7bd907e9809cc6a87dbf7b3a71.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 'src/lib/libc/crypt')
-rw-r--r--src/lib/libc/crypt/arc4random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c
index bbe42bd204..22b8d1f3c1 100644
--- a/src/lib/libc/crypt/arc4random.c
+++ b/src/lib/libc/crypt/arc4random.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: arc4random.c,v 1.18 2008/03/16 19:47:43 otto Exp $ */ 1/* $OpenBSD: arc4random.c,v 1.19 2008/06/04 00:50:23 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, David Mazieres <dm@uun.org> 4 * Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -231,7 +231,7 @@ arc4random_uniform(u_int32_t upper_bound)
231 min = 1 + ~upper_bound; /* 2**32 - upper_bound */ 231 min = 1 + ~upper_bound; /* 2**32 - upper_bound */
232 else { 232 else {
233 /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ 233 /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */
234 min = ((0xffffffff - (upper_bound << 2)) + 1) % upper_bound; 234 min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
235 } 235 }
236#endif 236#endif
237 237