]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemuMonitorTextGetMemoryStats: decrease risk of false positive in parsing
authorJim Meyering <meyering@redhat.com>
Fri, 5 Mar 2010 14:25:48 +0000 (15:25 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 5 Mar 2010 17:28:56 +0000 (18:28 +0100)
The code erroneously searched the entire "reply" for a comma, when
its intent was to search only that portion after "balloon: actual="
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetMemoryStats):
Search for "," only starting *after* the BALLOON_PREFIX string.
Otherwise, we'd be more prone to false positives.

src/qemu/qemu_monitor_text.c

index 7f0e7f65dc611d417c1b3002753ae920d11a6149..e629c6bd9b71f428f967b1a610228db76641380e 100644 (file)
@@ -593,7 +593,8 @@ int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
     }
 
     if ((offset = strstr(reply, BALLOON_PREFIX)) != NULL) {
-        if ((offset = strchr(reply, ',')) != NULL) {
+        offset += strlen(BALLOON_PREFIX);
+        if ((offset = strchr(offset, ',')) != NULL) {
             ret = qemuMonitorParseExtraBalloonInfo(offset, stats, nr_stats);
         }
     }