[libvirt] [PATCH 4/6] qemuMonitorTextGetAllBlockStatsInfo: Fix line validation

Michal Privoznik mprivozn at redhat.com
Tue May 31 10:33:30 UTC 2016


There's a bug in the function. We expect the following format for
the data we are parsing here:

  key: value

So we use strchr() to find ':' and then see if it is followed by
space. Well, the condition which checks that - we got it wrong.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_monitor_text.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 28a6e1b..9295219 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -892,7 +892,7 @@ qemuMonitorTextGetAllBlockStatsInfo(qemuMonitorPtr mon,
         /* extract device name and make sure that it's followed by
          * a colon and space */
         dev_name = line;
-        if (!(line = strchr(line, ':')) && line[1] != ' ') {
+        if (!(line = strchr(line, ':')) || line[1] != ' ') {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("info blockstats reply was malformed"));
             goto cleanup;
-- 
2.8.3




More information about the libvir-list mailing list