aboutsummaryrefslogtreecommitdiff
path: root/util-linux/seedrng.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/seedrng.c')
-rw-r--r--util-linux/seedrng.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/util-linux/seedrng.c b/util-linux/seedrng.c
index 5559ba77c..023ed8688 100644
--- a/util-linux/seedrng.c
+++ b/util-linux/seedrng.c
@@ -85,14 +85,14 @@ static bool read_new_seed(uint8_t *seed, size_t len)
85 return true; 85 return true;
86 } 86 }
87 if (ret < 0 && errno == ENOSYS) { 87 if (ret < 0 && errno == ENOSYS) {
88 struct pollfd random_fd = { 88 int fd = xopen("/dev/random", O_RDONLY);
89 .fd = xopen("/dev/random", O_RDONLY), 89 struct pollfd random_fd;
90 .events = POLLIN 90 random_fd.fd = fd;
91 }; 91 random_fd.events = POLLIN;
92 is_creditable = poll(&random_fd, 1, 0) == 1; 92 is_creditable = poll(&random_fd, 1, 0) == 1;
93//This is racy. is_creditable can be set to true here, but other process 93//This is racy. is_creditable can be set to true here, but other process
94//can consume "good" random data from /dev/urandom before we do it below. 94//can consume "good" random data from /dev/urandom before we do it below.
95 close(random_fd.fd); 95 close(fd);
96 } else { 96 } else {
97 if (getrandom(seed, len, GRND_INSECURE) == (ssize_t)len) 97 if (getrandom(seed, len, GRND_INSECURE) == (ssize_t)len)
98 return false; 98 return false;