util: xml: Disallow aliasing of negative numbers in virXPathUInt

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>
This commit is contained in:
Peter Krempa 2022-10-05 09:56:38 +02:00
parent 8989b3a54d
commit 3e3c52f10f

View 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;