Remove undefined behavior from sranddev() and
srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. Approved by: secteam MFC after: 3 days
This commit is contained in:
parent
af2bdacafb
commit
6a762eb23e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241373
@ -130,10 +130,9 @@ sranddev()
|
||||
|
||||
if (!done) {
|
||||
struct timeval tv;
|
||||
unsigned long junk;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
|
||||
srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,10 +312,9 @@ srandomdev(void)
|
||||
|
||||
if (!done) {
|
||||
struct timeval tv;
|
||||
volatile unsigned long junk;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
|
||||
srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user