Change 2 arc4random modulo operations to arc4random_uniform() as

OpenBSD does, since modulo is not power of 2.

Obtained from:  OpenBSD
This commit is contained in:
Andrey A. Chernov 2008-07-26 15:39:32 +00:00
parent 89aa52d4db
commit f90b161b21

View File

@ -894,7 +894,7 @@ set_short_delay(rai)
* already-scheduled time. RFC-2461 6.2.6 * already-scheduled time. RFC-2461 6.2.6
*/ */
#ifdef HAVE_ARC4RANDOM #ifdef HAVE_ARC4RANDOM
delay = arc4random() % MAX_RA_DELAY_TIME; delay = arc4random_uniform(MAX_RA_DELAY_TIME);
#else #else
delay = random() % MAX_RA_DELAY_TIME; delay = random() % MAX_RA_DELAY_TIME;
#endif #endif
@ -1661,7 +1661,7 @@ ra_timer_update(void *data, struct timeval *tm)
*/ */
interval = rai->mininterval; interval = rai->mininterval;
#ifdef HAVE_ARC4RANDOM #ifdef HAVE_ARC4RANDOM
interval += arc4random() % (rai->maxinterval - rai->mininterval); interval += arc4random_uniform(rai->maxinterval - rai->mininterval);
#else #else
interval += random() % (rai->maxinterval - rai->mininterval); interval += random() % (rai->maxinterval - rai->mininterval);
#endif #endif