]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainAudioOSSParse: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Tue, 18 May 2021 15:04:50 +0000 (17:04 +0200)
committerLaine Stump <laine@redhat.com>
Tue, 18 May 2021 16:27:14 +0000 (12:27 -0400)
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>
src/conf/domain_conf.c

index a46e64c64aaab9e55aa935bb54ddbea786579879..b3ed3a9c5aabd96103401b67f59d0b45ae6b4313 100644 (file)
@@ -13074,26 +13074,15 @@ static int
 virDomainAudioOSSParse(virDomainAudioIOOSS *def,
                        xmlNodePtr node)
 {
-    g_autofree char *tryPoll = virXMLPropString(node, "tryPoll");
-    g_autofree char *bufferCount = virXMLPropString(node, "bufferCount");
-
     def->dev = virXMLPropString(node, "dev");
 
-    if (tryPoll &&
-        ((def->tryPoll =
-          virTristateBoolTypeFromString(tryPoll)) <= 0)) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("unknown 'tryPoll' value '%s'"), tryPoll);
+    if (virXMLPropTristateBool(node, "tryPoll", VIR_XML_PROP_NONE,
+                               &def->tryPoll) < 0)
         return -1;
-    }
 
-    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;
 }