diff options
author | pfg <pfg@FreeBSD.org> | 2016-05-15 06:06:22 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-05-15 06:06:22 +0000 |
commit | ec09ab4e99768d7661a816af2bc3e104ae4db1ae (patch) | |
tree | baa3a491e472d051dbed020ba4dd50840c540372 | |
parent | 063f41234ab9e67bcaca772e6a93fed576feab34 (diff) | |
download | FreeBSD-src-ec09ab4e99768d7661a816af2bc3e104ae4db1ae.zip FreeBSD-src-ec09ab4e99768d7661a816af2bc3e104ae4db1ae.tar.gz |
routed(8): Use arc4random_uniform instead of arc4random.
Use arc4random_uniform() when the desired random number upper bound
is not a power of two.
While here, we don't need srandom() and friends anymore.
Obtained from: OpenBSD (CVS rev. 1.20)
-rw-r--r-- | sbin/routed/main.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/sbin/routed/main.c b/sbin/routed/main.c index a6202fb..4a8d3ca 100644 --- a/sbin/routed/main.c +++ b/sbin/routed/main.c @@ -303,11 +303,6 @@ usage: pidfile(0); #endif mypid = getpid(); -#ifdef __FreeBSD__ - srandomdev(); -#else - srandom((int)(clk.tv_sec ^ clk.tv_usec ^ mypid)); -#endif /* prepare socket connected to the kernel. */ @@ -826,8 +821,8 @@ intvl_random(struct timeval *tp, /* put value here */ { tp->tv_sec = (time_t)(hi == lo ? lo - : (lo + arc4random() % ((hi - lo)))); - tp->tv_usec = arc4random() % 1000000; + : (lo + arc4random_uniform(1 + hi - lo))); + tp->tv_usec = arc4random_uniform(1000000); } |