From: Christopher James Halse Rogers Date: Mon, 7 Aug 2017 06:10:51 +0000 (+1000) Subject: lib/randutils.c: More paranoia in getrandom() call. X-Git-Tag: v2.30.2~21 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e10ad091968dd9277274353fb6353f52fffe89e;p=thirdparty%2Futil-linux.git 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. --- diff --git a/lib/randutils.c b/lib/randutils.c index ceeb474eff..7d85dc8417 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;