svn commit: r299708 - head/usr.sbin/timed/timed
Pedro F. Giffuni
pfg at FreeBSD.org
Sat May 14 01:12:25 UTC 2016
Author: pfg
Date: Sat May 14 01:12:23 2016
New Revision: 299708
URL: https://svnweb.freebsd.org/changeset/base/299708
Log:
timed(8): Use stronger random number generator.
Using arc4random simplifies the code by not having to worry about
seeds which ironically depend on the time.
CID: 1300004
Modified:
head/usr.sbin/timed/timed/timed.c
Modified: head/usr.sbin/timed/timed/timed.c
==============================================================================
--- head/usr.sbin/timed/timed/timed.c Sat May 14 00:46:38 2016 (r299707)
+++ head/usr.sbin/timed/timed/timed.c Sat May 14 01:12:23 2016 (r299708)
@@ -229,12 +229,9 @@ main(int argc, char *argv[])
exit(1);
}
- /* choose a unique seed for random number generation */
- (void)gettimeofday(&ntime, NULL);
- srandom(ntime.tv_sec + ntime.tv_usec);
-
- sequence = random(); /* initial seq number */
+ sequence = arc4random(); /* initial seq number */
+ (void)gettimeofday(&ntime, NULL);
/* rounds kernel variable time to multiple of 5 ms. */
ntime.tv_sec = 0;
ntime.tv_usec = -((ntime.tv_usec/1000) % 5) * 1000;
More information about the svn-src-all
mailing list