Blame SOURCES/libvirt-util-check-for-an-illegal-character-in-a-XML-namespace-prefix.patch

898951
From 28894754f079527609645607bb44fb268259bf2c Mon Sep 17 00:00:00 2001
898951
Message-Id: <28894754f079527609645607bb44fb268259bf2c@dist-git>
898951
From: Erik Skultety <eskultet@redhat.com>
898951
Date: Thu, 22 Jan 2015 15:53:57 +0100
898951
Subject: [PATCH] util: check for an illegal character in a XML namespace
898951
 prefix
898951
898951
https://bugzilla.redhat.com/show_bug.cgi?id=1184929
898951
898951
When user tries to insert element metadata providing a namespace
898951
declaration as well, currently we insert the element without any validation
898951
check for XML prefix (if provided). The next VM start would then
898951
fail with parse error. This patch fixes this issue by adding a call to
898951
xmlValidateNCName function to check for illegal characters in the
898951
prefix.
898951
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1143921
898951
898951
(cherry picked from commit 2c22954f99a70ed654e4116a18f433afa24d41c5)
898951
898951
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
898951
---
898951
 src/util/virxml.c | 6 ++++++
898951
 1 file changed, 6 insertions(+)
898951
898951
diff --git a/src/util/virxml.c b/src/util/virxml.c
898951
index 88a1196..88c1fcc 100644
898951
--- a/src/util/virxml.c
898951
+++ b/src/util/virxml.c
898951
@@ -1074,6 +1074,12 @@ virXMLInjectNamespace(xmlNodePtr node,
898951
 {
898951
     xmlNsPtr ns;
898951
 
898951
+    if (xmlValidateNCName((const unsigned char *)key, 1) != 0) {
898951
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
898951
+                       _("failed to validate prefix for a new XML namespace"));
898951
+        return -1;
898951
+    }
898951
+
898951
     if (!(ns = xmlNewNs(node, (const unsigned char *)uri, (const unsigned char *)key))) {
898951
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
898951
                        _("failed to create a new XML namespace"));
898951
-- 
898951
2.2.1
898951