From: Michal Privoznik Date: Tue, 31 May 2016 10:23:24 +0000 (+0200) Subject: qemuMonitorTextGetAllBlockStatsInfo: Fix line validation X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c94720f86ad203a5ca6e669c8423f715946d4f5d;p=libvirt.git qemuMonitorTextGetAllBlockStatsInfo: Fix line validation 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 --- diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 28a6e1b372..9295219b3f 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;