mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virRandomBytes: Prefer saferead over plain read
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user