Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-03-21 00:29:03 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-03-21 00:29:03 +0300
commit2519f0ef0c24e4a0fec98b58e6f3481d5dd57acd (patch)
tree846b50429adea0b7d6eb0ff5b8ad7cd611990406
parent58988463cc16b95ca111b177fb89d666db33e546 (diff)
srandom: Replace accessing /dev/random by equivalent getentropy call
/dev/random calls getentropy. So there's no good reason to go out of our way to open /dev/random just to call getentropy anyway. * random.cc (srandomdev): Drop opening /dev/random in favor of calling getentropy. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/random.cc11
1 files changed, 1 insertions, 10 deletions
diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc
index fe1ac08fd..8cccadeef 100644
--- a/winsup/cygwin/random.cc
+++ b/winsup/cygwin/random.cc
@@ -299,7 +299,6 @@ dummy (unsigned volatile long *x)
void
srandomdev()
{
- int fd, done;
size_t len;
if (rand_type == TYPE_0)
@@ -307,15 +306,7 @@ srandomdev()
else
len = rand_deg * sizeof state[0];
- done = 0;
- fd = open("/dev/random", O_RDONLY, 0);
- if (fd >= 0) {
- if (read(fd, (void *) state, len) == (ssize_t) len)
- done = 1;
- close(fd);
- }
-
- if (!done) {
+ if (getentropy ((void *) state, len)) {
struct timeval tv;
unsigned long junk;