]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/randutils: reset lose counter
authorKarel Zak <kzak@redhat.com>
Mon, 14 Aug 2017 08:56:08 +0000 (10:56 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 20 Sep 2017 12:16:55 +0000 (14:16 +0200)
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>
lib/randutils.c

index 5cd1c9976e2901b641a9140d497d536633e52e08..43afc601d30fe51a54e8d78c922250117de36af1 100644 (file)
@@ -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);