Date: Sat, 14 May 2016 01:12:23 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299708 - head/usr.sbin/timed/timed Message-ID: <201605140112.u4E1CNZo078135@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605140112.u4E1CNZo078135>