]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainFeaturesDefParse: Use virXMLPropUInt
authorTim Wiederhake <twiederh@redhat.com>
Tue, 27 Apr 2021 11:12:54 +0000 (13:12 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 3 May 2021 09:17:40 +0000 (11:17 +0200)
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>
src/conf/domain_conf.c

index 1e88b6370b2e2bdd12d9844ea250eb2e3bac058d..a9b2580fd7d2c431cfe45e3587f1ad7716d7ea41 100644 (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",