From f45937c9cf21243a9671be8f742473b3ed45a6f0 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Tue, 27 Apr 2021 13:12:54 +0200 Subject: [PATCH] virDomainFeaturesDefParse: Use virXMLPropUInt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- src/conf/domain_conf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1e88b6370b..a9b2580fd7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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", -- 2.47.2