From: Lennart Poettering Date: Wed, 7 Nov 2018 17:37:13 +0000 (+0100) Subject: random-util: handle if getrandom() returns 0 X-Git-Tag: v240~380^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d68ccc08416ce0117c59a7ddac97d443f8239d12;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/basic/random-util.c b/src/basic/random-util.c index 5e4ed2da9d0..3989bb9dc61 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -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;