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.
This commit is contained in:
Christopher James Halse Rogers 2017-08-07 16:10:51 +10:00
parent a7df0f5f35
commit cc7d1fd16d
1 changed files with 1 additions and 1 deletions

View File

@ -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;