From dba14c305c2a73a2485473738456cac5575093a7 Mon Sep 17 00:00:00 2001 From: Hajimu UMEMOTO Date: Fri, 15 Aug 2003 17:51:51 +0000 Subject: [PATCH] use arc4random. Obtained from: KAME MFC after: 1 week --- usr.sbin/rtadvd/Makefile | 2 +- usr.sbin/rtadvd/rtadvd.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile index 179ba4ed7290..561883e943d8 100644 --- a/usr.sbin/rtadvd/Makefile +++ b/usr.sbin/rtadvd/Makefile @@ -18,7 +18,7 @@ PROG= rtadvd MAN= rtadvd.conf.5 rtadvd.8 SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c -CFLAGS+= -DINET6 -DHAVE_POLL_H +CFLAGS+= -DINET6 -DHAVE_ARC4RANDOM -DHAVE_POLL_H DPADD= ${LIBCOMPAT} LDADD= -lcompat diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index e0811cab3c43..f33a9518dcef 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -214,11 +214,13 @@ main(argc, argv) /* timer initialization */ rtadvd_timer_init(); +#ifndef HAVE_ARC4RANDOM /* random value initialization */ #ifdef __FreeBSD__ srandomdev(); #else srandom((u_long)time(NULL)); +#endif #endif /* get iflist block from kernel */ @@ -1634,7 +1636,11 @@ ra_timer_update(void *data, struct timeval *tm) * MaxRtrAdvInterval (RFC2461 6.2.4). */ interval = rai->mininterval; +#ifdef HAVE_ARC4RANDOM + interval += arc4random() % (rai->maxinterval - rai->mininterval); +#else interval += random() % (rai->maxinterval - rai->mininterval); +#endif /* * For the first few advertisements (up to