On Fri, Mar 05, 2010 at 03:29:56PM +0100, Jim Meyering wrote: > Not urgent. > > This was highlighted by clang as a dead store, since > the first result stored in "offset" was never used. > But if "info balloon" were ever to print some introductory > text (containing a comma) before the balloon: actual... line, > the bug would have made a difference. > > > >From c81c6af87f20740a6b75652937ec8346f8bf59e3 Mon Sep 17 00:00:00 2001 > From: Jim Meyering <meyering@xxxxxxxxxx> > Date: Fri, 5 Mar 2010 15:25:48 +0100 > Subject: [PATCH] qemuMonitorTextGetMemoryStats: decrease risk of false positive in parsing > > 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 | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c > index 7f0e7f6..e629c6b 100644 > --- a/src/qemu/qemu_monitor_text.c > +++ b/src/qemu/qemu_monitor_text.c > @@ -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); > } > } Right, it 'works' because BALLOON_PREFIX doesn't have a comma, but the patch makes the code consistent and more reliable, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@xxxxxxxxxxxx | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list