]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainDeviceDefValidateNetwork: Check for range only if IP prefix set
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 29 Jun 2018 14:48:55 +0000 (16:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 3 Jul 2018 02:56:29 +0000 (04:56 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1515533

The @prefix attribute to <ip/> element for interface type user is
optional. Therefore, if left out it has value of zero in which
case we should not check whether it falls into <4, 27> range.
Otherwise we fail parsing domain XML for no good reason.

Broken by commit b62b8090b2ad4524a5bf9d40d0d1c17a9d57f5a0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 4c15d5a36a8f95366e420f75e809e149686e03f6..8c22b17c1ffa025b240d88d9d2935d6909eaab93 100644 (file)
@@ -4373,7 +4373,8 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
                 }
                 hasIPv4 = true;
 
-                if (ip->prefix < 4 || ip->prefix > 27) {
+                if (ip->prefix > 0 &&
+                    (ip->prefix < 4 || ip->prefix > 27)) {
                     virReportError(VIR_ERR_XML_ERROR, "%s",
                                    _("invalid prefix, must be in range of 4-27"));
                     return -1;