]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Check if number of vCPUs fits in the storage variable
authorPeter Krempa <pkrempa@redhat.com>
Tue, 22 Jan 2013 14:27:04 +0000 (15:27 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 22 Jan 2013 16:36:46 +0000 (17:36 +0100)
The count of vCPUs for a domain is extracted as a usingned long variable
but is stored in a unsigned short. If the actual number was too large,
a faulty number was stored.

src/conf/domain_conf.c

index 7640af7888b38d3ce194e99148981aa285359a78..26e0b8eb6e31e7cf4cfa2ea18f07b9f64e5eebdf 100644 (file)
@@ -9085,7 +9085,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         def->maxvcpus = 1;
     } else {
         def->maxvcpus = count;
-        if (count == 0) {
+        if (count == 0 || (unsigned short) count != count) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("invalid maxvcpus %lu"), count);
             goto error;
@@ -9101,7 +9101,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         def->vcpus = def->maxvcpus;
     } else {
         def->vcpus = count;
-        if (count == 0) {
+        if (count == 0 || (unsigned short) count != count) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("invalid current vcpus %lu"), count);
             goto error;