]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virRandomBytes: Prefer saferead over plain read
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 29 May 2018 06:55:28 +0000 (08:55 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 Jun 2018 08:31:19 +0000 (10:31 +0200)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virrandom.c

index bfd044df556b32df9f15905d22f571cd060bfbb9..4283611065508967037ccf54b329f1d3805e7edc 100644 (file)
@@ -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;
         }