[PATCH 1/2] virPerfReadEvent: Prefer saferead over read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do I really need to explain why?
Well, if read() is interrupted int the middle of reading, we will
never read the rest (even though it's highly unlikely as we are
reading just 8 bytes).

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/util/virperf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virperf.c b/src/util/virperf.c
index 9dc4e25..359a9c3 100644
--- a/src/util/virperf.c
+++ b/src/util/virperf.c
@@ -247,7 +247,7 @@ virPerfReadEvent(virPerfPtr perf,
     if (event == NULL || !event->enabled)
         return -1;
 
-    if (read(event->fd, value, sizeof(uint64_t)) < 0) {
+    if (saferead(event->fd, value, sizeof(uint64_t)) < 0) {
         virReportSystemError(errno, "%s",
                              _("Unable to read cache data"));
         return -1;
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]