virDomainAudioSDLParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `bufferCount`.

`bufferCount` does not benefit from being referable as e.g. "-7" for
requesting 4294967289 buffers, as this value is distinctly out of range
for normal use.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-04-27 13:12:57 +02:00 committed by Ján Tomko
parent 4fc365934a
commit 8b901da616

View File

@ -13494,15 +13494,9 @@ static int
virDomainAudioSDLParse(virDomainAudioIOSDL *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;
}