
On 07/01/2011 07:25 AM, Eric Blake wrote:
To avoid regressions, we let callers specify whether to require a micro version. Callers that were parsing uname() output benefit from the defaults, whereas callers that were parsing version strings from other sources should not change in behavior.
* src/util/util.c (virParseVersionString): Allow caller to choose whether to fail if micro is missing. * src/util/util.h (virParseVersionString): Update signature. * src/esx/esx_driver.c (esxGetVersion): Update callers. * src/lxc/lxc_driver.c (lxcVersion): Likewise. * src/openvz/openvz_conf.c (openvzExtractVersionInfo): Likewise. * src/uml/uml_driver.c (umlGetVersion): Likewise. * src/vbox/vbox_MSCOMGlue.c (vboxLookupVersionInRegistry): Likewise. * src/vbox/vbox_tmpl.c (vboxExtractVersion): Likewise. * src/vmware/vmware_conf.c (vmwareExtractVersion): Likewise. * src/xenapi/xenapi_driver.c (xenapiGetVersion): Likewise. Reported by Matthias Bolte.
I plan to squash this in (I figured it was easier to show this diff than to send a full v2): diff --git i/src/util/util.c w/src/util/util.c index 8e12e5f..6e1f4f5 100644 --- i/src/util/util.c +++ w/src/util/util.c @@ -1619,6 +1619,9 @@ virParseVersionString(const char *str, unsigned long *version, if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, µ) < 0) return -1; + if (major > ULONG_MAX / 1000000 || minor > 999 || micro > 999) + return -1; + *version = 1000000 * major + 1000 * minor + micro; return 0; -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org