From a6be5a4ce105975fd106f094411671d0d3b69445 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 29 May 2018 08:55:28 +0200 Subject: [PATCH] virRandomBytes: Prefer saferead over plain read Signed-off-by: Michal Privoznik --- src/util/virrandom.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/virrandom.c b/src/util/virrandom.c index bfd044df55..4283611065 100644 --- a/src/util/virrandom.c +++ b/src/util/virrandom.c @@ -182,9 +182,7 @@ virRandomBytes(unsigned char *buf, while (buflen > 0) { ssize_t n; - if ((n = read(fd, buf, buflen)) <= 0) { - if (errno == EINTR) - continue; + if ((n = saferead(fd, buf, buflen)) <= 0) { VIR_FORCE_CLOSE(fd); return n < 0 ? -errno : -ENODATA; }