virDomainAudioCoreAudioParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `bufferCount`. 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:
Tim Wiederhake 2021-05-18 17:04:49 +02:00 committed by Laine Stump
parent 7423635e46
commit 23e763eb46

View File

@ -13046,15 +13046,9 @@ static int
virDomainAudioCoreAudioParse(virDomainAudioIOCoreAudio *def,
xmlNodePtr node)
{
g_autofree char *bufferCount = virXMLPropString(node, "bufferCount");
if (bufferCount &&
virStrToLong_ui(bufferCount, NULL, 10,
&def->bufferCount) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("cannot parse 'bufferCount' value '%s'"), bufferCount);
if (virXMLPropUInt(node, "bufferCount", 10, VIR_XML_PROP_NONE,
&def->bufferCount) < 0)
return -1;
}
return 0;
}