In the extremely miniscule chance that read_random returns <= 0, don't try

and use that return code as a modulus (panics are bad, mmmkay?)
This commit is contained in:
Dan Moschuk 1999-11-29 19:23:35 +00:00
parent 8b6c02f328
commit e6082d1936
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53893

View File

@ -41,8 +41,12 @@ arc4_randomstir (void)
int r, n;
r = read_random(key, sizeof(key));
for (n = r; n < sizeof(key); n++)
key[n] = key[n % r];
/* if r == 0 || -1, just use what was on the stack */
if (r > 0)
{
for (n = r; n < sizeof(key); n++)
key[n] = key[n % r];
}
for (n = 0; n < 256; n++)
{