From 320ea3a47ec7a2ff82615cdb39b682ef50623da0 Mon Sep 17 00:00:00 2001 From: Jim Fehlig Date: Wed, 31 Mar 2010 17:02:57 -0600 Subject: [PATCH] Only parse 'CPU XML' in virCPUDefParseXML() 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index cf91930365..c51ac4e752 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -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; -- GitLab