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:
parent
69cdab8aa8
commit
1bd762c01a
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user