From cc7d1fd16d14acf08a20fbe3a6426d2cb4878768 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Mon, 7 Aug 2017 16:10:51 +1000 Subject: lib/randutils.c: More paranoia in getrandom() call. If getrandom() is called with nbytes ≥ 256 then it can return with less than the requested bytes filled. In this case we *could* adjust the buffer by the number of bytes actually read, but it's simpler to just redo the call. --- lib/randutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/randutils.c') diff --git a/lib/randutils.c b/lib/randutils.c index ceeb474ef..7d85dc841 100644 --- a/lib/randutils.c +++ b/lib/randutils.c @@ -100,7 +100,7 @@ void random_get_bytes(void *buf, size_t nbytes) #ifdef HAVE_GETRANDOM errno = 0; - while (getrandom(buf, nbytes, 0) < 0) { + while (getrandom(buf, nbytes, 0) != (ssize_t)nbytes) { if (errno == EINTR) continue; break; -- cgit v1.2.3-55-g7522