mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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 <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
99037fb2b9
commit
3d5591aede
@ -417,19 +417,17 @@ int
|
|||||||
virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
|
virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
|
||||||
virDomainDeviceSpaprVioAddress *addr)
|
virDomainDeviceSpaprVioAddress *addr)
|
||||||
{
|
{
|
||||||
g_autofree char *reg = virXMLPropString(node, "reg");
|
int reg;
|
||||||
|
|
||||||
memset(addr, 0, sizeof(*addr));
|
memset(addr, 0, sizeof(*addr));
|
||||||
|
|
||||||
if (reg) {
|
if ((reg = virXMLPropULongLong(node, "reg", 16, VIR_XML_PROP_NONE,
|
||||||
if (virStrToLong_ull(reg, NULL, 16, &addr->reg) < 0) {
|
&addr->reg)) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
return -1;
|
||||||
_("Cannot parse <address> 'reg' attribute"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (reg != 0)
|
||||||
addr->has_reg = true;
|
addr->has_reg = true;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user