random-util: handle if getrandom() returns 0
This should normally not happen, but given that the man page suggests something about this in the context of interruption, let's handle this and propagate an I/O error.
This commit is contained in:
@@ -93,6 +93,9 @@ int genuine_random_bytes(void *p, size_t n, bool high_quality_required) {
|
||||
}
|
||||
|
||||
already_done = r;
|
||||
} else if (r == 0) {
|
||||
have_syscall = true;
|
||||
return -EIO;
|
||||
} else if (errno == ENOSYS)
|
||||
/* We lack the syscall, continue with reading from /dev/urandom. */
|
||||
have_syscall = false;
|
||||
|
||||
Reference in New Issue
Block a user