]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: xml: Disallow aliasing of negative numbers in virXPathULongLong
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:56 +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 long long from
XPaths.

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

index 35c03407799d1bb281e407bfeecde7bb4e065ea9..067fef8856ccf9dde579eeed85b45f0497749e24 100644 (file)
@@ -323,7 +323,7 @@ virXPathULongLong(const char *xpath,
     if (!(obj = virXPathEvalString(xpath, ctxt)))
         return -1;
 
-    if (virStrToLong_ull((char *) obj->stringval, NULL, 10, value) < 0)
+    if (virStrToLong_ullp((char *) obj->stringval, NULL, 10, value) < 0)
         return -2;
 
     return 0;