[libvirt] [PATCH] util: check for an illegal character in a XML namespace prefix

Erik Skultety eskultet at redhat.com
Wed Dec 10 09:28:12 UTC 2014



On 12/05/2014 12:57 PM, Michal Privoznik wrote:
> On 04.12.2014 14:37, Erik Skultety wrote:
>> When user tries to insert element metadata providing a namespace
>> declaration as well, currently we insert the element without any
>> validation
>> check for XML prefix (if provided). The next VM start would then
>> fail with parse error. This patch fixes this issue by adding a call to
>> xmlValidateNCName function to check for illegal characters in the
>> prefix.
>> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1143921
>> ---
>>   src/util/virxml.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/src/util/virxml.c b/src/util/virxml.c
>> index 7f591fb..93f8590 100644
>> --- a/src/util/virxml.c
>> +++ b/src/util/virxml.c
>> @@ -1066,6 +1066,12 @@ virXMLInjectNamespace(xmlNodePtr node,
>>   {
>>       xmlNsPtr ns;
>>
>> +    if (xmlValidateNCName((const unsigned char *)key, 1) != 0) {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>> +                       _("failed to validate prefix for a new XML
>> namespace"));
>> +        return -1;
>> +    }
>> +
>>       if (!(ns = xmlNewNs(node, (const unsigned char *)uri, (const
>> unsigned char *)key))) {
>>           virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>>                          _("failed to create a new XML namespace"));
>>
>
> ACKed and pushed.
>
> Michal

Thanks, Michal.




More information about the libvir-list mailing list