]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Only parse 'CPU XML' in virCPUDefParseXML()
authorJim Fehlig <jfehlig@novell.com>
Wed, 31 Mar 2010 23:02:57 +0000 (17:02 -0600)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 1 Apr 2010 12:04:43 +0000 (14:04 +0200)
Received report of user crashing libvirtd with

virsh capabilities > capabilities.xml
virsh cpu-compare capabilities.xml

While user has been informed about proper usage of cpu-compare,
segfaulting libvirt should be avoided.

Do not parse CPU definition in virCPUDefParseXML() if XML is not
a 'cpu' node.

src/conf/cpu_conf.c

index cf91930365885901a61a3c26752b657a8f2945c5..c51ac4e75261ce4a606a7b91f22311e67fd3fc47 100644 (file)
@@ -115,6 +115,13 @@ virCPUDefParseXML(const xmlNodePtr node,
     int n;
     unsigned int i;
 
+    if (!xmlStrEqual(node->name, BAD_CAST "cpu")) {
+        virCPUReportError(VIR_ERR_INTERNAL_ERROR,
+                          "%s",
+                          _("XML does not contain expected 'cpu' element"));
+        return NULL;
+    }
+
     if (VIR_ALLOC(def) < 0) {
         virReportOOMError();
         return NULL;