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
This commit is contained in:
pfg 2016-05-14 01:12:23 +00:00
parent 69cdab8aa8
commit 1bd762c01a

View File

@ -229,12 +229,9 @@ main(int argc, char *argv[])
exit(1);
}
/* choose a unique seed for random number generation */
sequence = arc4random(); /* initial seq number */
(void)gettimeofday(&ntime, NULL);
srandom(ntime.tv_sec + ntime.tv_usec);
sequence = random(); /* initial seq number */
/* rounds kernel variable time to multiple of 5 ms. */
ntime.tv_sec = 0;
ntime.tv_usec = -((ntime.tv_usec/1000) % 5) * 1000;