diff options
author | ache <ache@FreeBSD.org> | 2008-07-21 12:44:47 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2008-07-21 12:44:47 +0000 |
commit | 101cbb7cb3db72e499cc35d9319dac30b653d25b (patch) | |
tree | 926a4a725525d0dab3bac76e75cc9b8f473a019c /lib | |
parent | 4497a308d1b105200afe2b2fd35e6ebfba8b5e0f (diff) | |
download | FreeBSD-src-101cbb7cb3db72e499cc35d9319dac30b653d25b.zip FreeBSD-src-101cbb7cb3db72e499cc35d9319dac30b653d25b.tar.gz |
Decrease arc4_count only when needed and with proper bytes amount.
Obtained from: OpenBSD
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/arc4random.c | 3 |
1 files changed, 2 insertions, 1 deletions
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); |