mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
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
7ffbd1b5b0
commit
555470a31d
1 changed files with 2 additions and 5 deletions
|
|
@ -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 a new issue