mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-09 20:58:33 +03: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,
|
||||
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 <address> '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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user