]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: xml: Disallow aliasing of negative numbers in virXPathUInt
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Oct 2022 07:56:38 +0000 (09:56 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 2 Nov 2022 08:20:57 +0000 (09:20 +0100)
Passing negative number as an alias for the max value is an anti-feature
we unfortunately allowed in virsh, but luckily never encouraged in the
XML.

Refuse numbers with negative sign when parsing unsigned int from
XPaths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virxml.c

index a47a5d49fc46ab4fb76ade1d9eab87478736a5e8..d80a69f1639b6f3c40285156d3ee97c1b1ab36bb 100644 (file)
@@ -253,7 +253,7 @@ virXPathUIntBase(const char *xpath,
     if (!(obj = virXPathEvalString(xpath, ctxt)))
         return -1;
 
-    if (virStrToLong_ui((char *) obj->stringval, NULL, base, value) < 0)
+    if (virStrToLong_uip((char *) obj->stringval, NULL, base, value) < 0)
         return -2;
 
     return 0;