Blame SOURCES/libvirt-qemuDomainDeviceDefValidateNetwork-Check-for-range-only-if-IP-prefix-set.patch

982648
From b8f548e00daaf08ce34c2b8578e5a2b032b082b7 Mon Sep 17 00:00:00 2001
982648
Message-Id: <b8f548e00daaf08ce34c2b8578e5a2b032b082b7@dist-git>
982648
From: Michal Privoznik <mprivozn@redhat.com>
982648
Date: Mon, 9 Jul 2018 12:07:39 +0200
982648
Subject: [PATCH] qemuDomainDeviceDefValidateNetwork: Check for range only if
982648
 IP prefix set
982648
982648
https://bugzilla.redhat.com/show_bug.cgi?id=1515533
982648
982648
The @prefix attribute to <ip/> element for interface type user is
982648
optional. Therefore, if left out it has value of zero in which
982648
case we should not check whether it falls into <4, 27> range.
982648
Otherwise we fail parsing domain XML for no good reason.
982648
982648
Broken by commit b62b8090b2ad4524a5bf9d40d0d1c17a9d57f5a0.
982648
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
(cherry picked from commit a6fbbce73e2965edde45ece7c034e4b39bb8405d)
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
982648
---
982648
 src/qemu/qemu_domain.c | 3 ++-
982648
 1 file changed, 2 insertions(+), 1 deletion(-)
982648
982648
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
982648
index fa952f8306..f9bcf76f44 100644
982648
--- a/src/qemu/qemu_domain.c
982648
+++ b/src/qemu/qemu_domain.c
982648
@@ -4386,7 +4386,8 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
982648
                 }
982648
                 hasIPv4 = true;
982648
 
982648
-                if (ip->prefix < 4 || ip->prefix > 27) {
982648
+                if (ip->prefix > 0 &&
982648
+                    (ip->prefix < 4 || ip->prefix > 27)) {
982648
                     virReportError(VIR_ERR_XML_ERROR, "%s",
982648
                                    _("invalid prefix, must be in range of 4-27"));
982648
                     return -1;
982648
-- 
982648
2.18.0
982648