virRandomBytes: Prefer saferead over plain read

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2018-05-29 08:55:28 +02:00
parent c3320d6518
commit a6be5a4ce1
1 changed files with 1 additions and 3 deletions

View File

@ -182,9 +182,7 @@ virRandomBytes(unsigned char *buf,
while (buflen > 0) { while (buflen > 0) {
ssize_t n; ssize_t n;
if ((n = read(fd, buf, buflen)) <= 0) { if ((n = saferead(fd, buf, buflen)) <= 0) {
if (errno == EINTR)
continue;
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
return n < 0 ? -errno : -ENODATA; return n < 0 ? -errno : -ENODATA;
} }