diff options
author | Ed Maste <emaste@FreeBSD.org> | 2024-06-03 16:17:02 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2024-06-03 16:19:54 +0000 |
commit | 1b2aa3deeb0dbbace9fed635fa01b6f6e8480901 (patch) | |
tree | d4f991a92b1c7c84e264b900f50f2fa0202c872a /compat/arc4random_uniform.c | |
parent | 96dba636abec6d5451820add99300bda2ca6d86a (diff) |
Diffstat (limited to 'compat/arc4random_uniform.c')
-rw-r--r-- | compat/arc4random_uniform.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compat/arc4random_uniform.c b/compat/arc4random_uniform.c index 0f1b7b296759..4511722909b3 100644 --- a/compat/arc4random_uniform.c +++ b/compat/arc4random_uniform.c @@ -1,3 +1,5 @@ +/* $OpenBSD: arc4random_uniform.c,v 1.3 2019/01/20 02:59:07 bcook Exp $ */ + /* * Copyright (c) 2008, Damien Miller <djm@openbsd.org> * @@ -48,9 +50,11 @@ arc4random_uniform(uint32_t upper_bound) * number inside the range we need, so it should rarely need * to re-roll. */ - do + for (;;) { r = arc4random(); - while (r < min); + if (r >= min) + break; + } return r % upper_bound; } |