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:
parent
a7df0f5f35
commit
cc7d1fd16d
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue