]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainDeviceUSBMasterParseXML: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Tue, 18 May 2021 15:04:44 +0000 (17:04 +0200)
committerLaine Stump <laine@redhat.com>
Tue, 18 May 2021 16:27:12 +0000 (12:27 -0400)
This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `startport`. 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 661fa53206a3dc66113b6d8853748ba1a0c7663d..86680e0cdbe3aa7e2dedb134ce3837e5b70f7dc7 100644 (file)
@@ -6439,18 +6439,11 @@ static int
 virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
                                  virDomainDeviceUSBMaster *master)
 {
-    g_autofree char *startport = NULL;
-
     memset(master, 0, sizeof(*master));
 
-    startport = virXMLPropString(node, "startport");
-
-    if (startport &&
-        virStrToLong_ui(startport, NULL, 10, &master->startport) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <master> 'startport' attribute"));
+    if (virXMLPropUInt(node, "startport", 10, VIR_XML_PROP_NONE,
+                       &master->startport) < 0)
         return -1;
-    }
 
     return 0;
 }