summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2017-08-14 10:56:08 +0200
committerKarel Zak2017-08-14 10:56:08 +0200
commit51013d3efadc47efed76bb2cdf6aa1444dacdb95 (patch)
tree0d72aebbd628d724ee0d4a7022784c890af66a16 /lib
parentlib/randutils: improve getrandom() usage (diff)
downloadkernel-qcow2-util-linux-51013d3efadc47efed76bb2cdf6aa1444dacdb95.tar.gz
kernel-qcow2-util-linux-51013d3efadc47efed76bb2cdf6aa1444dacdb95.tar.xz
kernel-qcow2-util-linux-51013d3efadc47efed76bb2cdf6aa1444dacdb95.zip
lib/randutils: reset lose counter
It's probaly good idea to reset lose counter when we fallback from getrandom() to /dev/urandom. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/randutils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/randutils.c b/lib/randutils.c
index 5cd1c9976..43afc601d 100644
--- a/lib/randutils.c
+++ b/lib/randutils.c
@@ -120,7 +120,6 @@ void random_get_bytes(void *buf, size_t nbytes)
if (errno == ENOSYS)
#endif
-
/*
* We've been built against headers that support getrandom, but the
* running kernel does not. Fallback to reading from /dev/{u,}random
@@ -129,6 +128,7 @@ void random_get_bytes(void *buf, size_t nbytes)
{
int fd = random_get_fd();
+ lose_counter = 0;
if (fd >= 0) {
while (n > 0) {
ssize_t x = read(fd, cp, n);