From: Tim Wiederhake Date: Wed, 19 May 2021 14:10:12 +0000 (+0200) Subject: virDomainDeviceSpaprVioAddressParseXML: Use virXMLProp* X-Git-Tag: v7.4.0-rc1~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d5591aede2a917c3c2384720ed6dab8574dfabb;p=thirdparty%2Flibvirt.git virDomainDeviceSpaprVioAddressParseXML: Use virXMLProp* This strictens the parser to disallow negative values (interpreted as `ULLONG_MAX + value + 1`) for attribute `reg`. Allowing negative numbers to be interpreted this way makes no sense for this attribute, as it refers to a 32 bit address space. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 034f072df4..e587d90c59 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -417,19 +417,17 @@ int virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node, virDomainDeviceSpaprVioAddress *addr) { - g_autofree char *reg = virXMLPropString(node, "reg"); + int reg; memset(addr, 0, sizeof(*addr)); - if (reg) { - if (virStrToLong_ull(reg, NULL, 16, &addr->reg) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'reg' attribute")); - return -1; - } + if ((reg = virXMLPropULongLong(node, "reg", 16, VIR_XML_PROP_NONE, + &addr->reg)) < 0) + return -1; + if (reg != 0) addr->has_reg = true; - } + return 0; }