virDomainFeaturesDefParse: Use virXMLPropUInt

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `retries`. UINT_MAX holds no
special significance for this attribute and is distinctly out of range
for normal use.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-04-27 13:12:54 +02:00 committed by Ján Tomko
parent 47896e0ba2
commit f45937c9cf

View File

@ -18147,12 +18147,10 @@ virDomainFeaturesDefParse(virDomainDef *def,
if (value != VIR_TRISTATE_SWITCH_ON)
break;
if (virXPathUInt("string(./@retries)", ctxt,
&def->hyperv_spinlocks) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid HyperV spinlock retry count"));
if (virXMLPropUInt(nodes[i], "retries", 0,
VIR_XML_PROP_REQUIRED,
&def->hyperv_spinlocks) < 0)
return -1;
}
if (def->hyperv_spinlocks < 0xFFF) {
virReportError(VIR_ERR_XML_ERROR, "%s",