[libvirt] [PATCH 1/3] Re-factor qemu version parsing
Mark McLoughlin
markmc at redhat.com
Wed Jun 10 20:01:58 UTC 2009
On Wed, 2009-06-10 at 13:21 +0100, Daniel P. Berrange wrote:
> > + char *eol = strchr(help, '\n');
> > + if (eol) *eol = '\0';
>
> IIUC this NULL terminates the 'help' string on the first line, which
> will surely break....
>
> >
> > - if (!kvm_version &&
> > - sscanf(help, "QEMU PC emulator version %u.%u.%u",
> > - &major, &minor, µ) != 3) {
> > - char *eol = strchr(help, '\n');
> > - if (eol) *eol = '\0';
> > - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
> > - _("cannot parse QEMU version number in '%s'"),
> > - help);
> > + if (qemudParseVersionStr(help, &version, &kvm_version) == -1)
> > goto cleanup2;
> > - }
> > -
> > - version = (major * 1000 * 1000) + (minor * 1000) + micro;
> >
> > if (strstr(help, "-no-kqemu"))
> > flags |= QEMUD_CMD_FLAG_KQEMU;
>
> ....this code which looks at subsequent lines of 'help' ?
Nice catch Dan, thanks. Another version coming up which includes tests
for the flags computation, which would have caught this thinko.
Cheers,
Mark.
More information about the libvir-list
mailing list