virDomainAudioPulseAudioParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `latency`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-05-19 16:10:03 +02:00 committed by Michal Privoznik
parent 667dea5a1e
commit 15670ebb17

View File

@ -13092,18 +13092,12 @@ static int
virDomainAudioPulseAudioParse(virDomainAudioIOPulseAudio *def,
xmlNodePtr node)
{
g_autofree char *latency = virXMLPropString(node, "latency");
def->name = virXMLPropString(node, "name");
def->streamName = virXMLPropString(node, "streamName");
if (latency &&
virStrToLong_ui(latency, NULL, 10,
&def->latency) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse 'latency' value '%s'"), latency);
if (virXMLPropUInt(node, "latency", 10, VIR_XML_PROP_NONE,
&def->latency) < 0)
return -1;
}
return 0;
}