From 101cbb7cb3db72e499cc35d9319dac30b653d25b Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 21 Jul 2008 12:44:47 +0000 Subject: Decrease arc4_count only when needed and with proper bytes amount. Obtained from: OpenBSD --- lib/libc/gen/arc4random.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index c9f1e7f..6aa2323 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -167,7 +167,7 @@ arc4_check_init(void) static void arc4_check_stir(void) { - if (!rs_stired || --arc4_count == 0) { + if (!rs_stired || arc4_count <= 0) { arc4_stir(&rs); rs_stired = 1; } @@ -202,6 +202,7 @@ arc4random(void) arc4_check_init(); arc4_check_stir(); rnd = arc4_getword(&rs); + arc4_count -= 4; THREAD_UNLOCK(); return (rnd); -- cgit v1.1