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
@ -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