mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 14:35:25 +00:00
virDomainDeviceUSBMasterParseXML: Use virXMLProp*
This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `startport`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
793e71ee76
commit
081f22c209
@ -6439,18 +6439,11 @@ static int
|
|||||||
virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
|
virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
|
||||||
virDomainDeviceUSBMaster *master)
|
virDomainDeviceUSBMaster *master)
|
||||||
{
|
{
|
||||||
g_autofree char *startport = NULL;
|
|
||||||
|
|
||||||
memset(master, 0, sizeof(*master));
|
memset(master, 0, sizeof(*master));
|
||||||
|
|
||||||
startport = virXMLPropString(node, "startport");
|
if (virXMLPropUInt(node, "startport", 10, VIR_XML_PROP_NONE,
|
||||||
|
&master->startport) < 0)
|
||||||
if (startport &&
|
|
||||||
virStrToLong_ui(startport, NULL, 10, &master->startport) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Cannot parse <master> 'startport' attribute"));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user