1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-22 15:47:37 +00:00

Decrease arc4_count only when needed and with proper bytes amount.

Obtained from:  OpenBSD
This commit is contained in:
Andrey A. Chernov 2008-07-21 12:44:47 +00:00
parent 0761bd1fe1
commit b6634bf8d2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=180656

View File

@ -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);