[libvirt] [PATCH 1/2] virPerfReadEvent: Prefer saferead over read
Michal Privoznik
mprivozn at redhat.com
Thu Mar 31 14:48:23 UTC 2016
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 at redhat.com>
---
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
More information about the libvir-list
mailing list