]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMonitorTextGetAllBlockStatsInfo: Fix line validation
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 31 May 2016 10:23:24 +0000 (12:23 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 31 May 2016 11:06:55 +0000 (13:06 +0200)
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. But the check that does just that is slightly incorrect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor_text.c

index 28a6e1b3722fba5a712786d893528714970651c9..9295219b3ff7d87bb856787c88acfe4742ae2064 100644 (file)
@@ -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;