]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_x86: Require <cpuid> within <feature> in CPU map
authorJiri Denemark <jdenemar@redhat.com>
Wed, 13 Mar 2019 09:23:01 +0000 (10:23 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 8 Apr 2019 13:28:59 +0000 (15:28 +0200)
A feature with no cpuid element is invalid and it should not be silently
treated as a feature with all CPUID bits set to zero.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index 3b87386270acca0b5e9954a431d1ca382afdb5bf..3a8e3dd37fd2c8e5c3dfb1bce0f3d739be4be489 100644 (file)
@@ -924,6 +924,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
     if (n < 0)
         goto cleanup;
 
+    if (n == 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Missing cpuid for feature %s"),
+                       feature->name);
+        goto cleanup;
+    }
+
     for (i = 0; i < n; i++) {
         ctxt->node = nodes[i];
         if (x86ParseCPUID(ctxt, &cpuid) < 0) {