diff options
author | lloyd <[email protected]> | 2009-07-02 23:46:35 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-07-02 23:46:35 +0000 |
commit | 88cfd2b1f814272cde16930e687187ec9107427f (patch) | |
tree | ef5c41213bef9f1ca8677272b76a7281783f6718 /src/entropy | |
parent | 06adeee388ba66957d8cdad4dc0567398cc930c4 (diff) |
Fix a subtle bug in the /dev/*random reader. The maximum ms wait time was
set to 1000 ms (scaling based on amount of data requested). At 1000 ms
exactly, we would form a timeval of 0 seconds and 1000000 usecs (ie, 1 second).
Linux was fine with this, but FreeBSD 7.0's select was returning EINVAL.
Fix things to properly create the timeval so that everyone is happy.
Diffstat (limited to 'src/entropy')
-rw-r--r-- | src/entropy/dev_random/es_dev.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/entropy/dev_random/es_dev.cpp b/src/entropy/dev_random/es_dev.cpp index e6033753d..ef3074194 100644 --- a/src/entropy/dev_random/es_dev.cpp +++ b/src/entropy/dev_random/es_dev.cpp @@ -40,8 +40,9 @@ u32bit Device_EntropySource::Device_Reader::get(byte out[], u32bit length, FD_SET(fd, &read_set); struct ::timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = ms_wait_time * 1000; + + timeout.tv_sec = (ms_wait_time / 1000); + timeout.tv_usec = (ms_wait_time % 1000) * 1000; if(::select(fd + 1, &read_set, 0, 0, &timeout) < 0) return 0; |