]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainAudioSDLParse: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Tue, 27 Apr 2021 11:12:57 +0000 (13:12 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 3 May 2021 09:17:40 +0000 (11:17 +0200)
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>
src/conf/domain_conf.c

index adcba8a8e999ee59b1bd53935e5d7da19ec731e4..cb668d3d5e8bd16d1ea8417115f37cae78af1199 100644 (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;
 }