File libvirt-virNetDevBandwidthEqual-Make-it-more-robust.patch of Package libvirt

From 5159ff65a2bb9f5d53c80c4a1ede61dca22c1b62 Mon Sep 17 00:00:00 2001
Message-Id: <5159ff65a2bb9f5d53c80c4a1ede61dca22c1b62.1381312399.git.jdenemar@redhat.com>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Wed, 2 Oct 2013 11:02:13 +0200
Subject: [PATCH] virNetDevBandwidthEqual: Make it more robust

https://bugzilla.redhat.com/show_bug.cgi?id=1014198

So far the virNetDevBandwidthEqual() expected both ->in and ->out items
to be allocated for both @a and @b compared. This is not necessary true
for all our code. For instance, running 'update-device' twice over a NIC
with the very same XML results in SIGSEGV-ing in this function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ee02fbc8e4a24c1347761ceff2ddb2c108e9611c)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virnetdevbandwidth.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
index 71c272e..cd40a11 100644
--- a/src/util/virnetdevbandwidth.c
+++ b/src/util/virnetdevbandwidth.c
@@ -339,16 +339,30 @@ virNetDevBandwidthEqual(virNetDevBandwidthPtr a,
         return false;
 
     /* in */
-    if (a->in->average != b->in->average ||
-        a->in->peak != b->in->peak ||
-        a->in->burst != b->in->burst)
+    if (a->in) {
+        if (!b->in)
+            return false;
+
+        if (a->in->average != b->in->average ||
+            a->in->peak != b->in->peak ||
+            a->in->burst != b->in->burst)
+            return false;
+    } else if (b->in) {
         return false;
+    }
 
     /*out*/
-    if (a->out->average != b->out->average ||
-        a->out->peak != b->out->peak ||
-        a->out->burst != b->out->burst)
+    if (a->out) {
+        if (!b->out)
+            return false;
+
+        if (a->out->average != b->out->average ||
+            a->out->peak != b->out->peak ||
+            a->out->burst != b->out->burst)
+            return false;
+    } else if (b->out) {
         return false;
+    }
 
     return true;
 }
-- 
1.8.3.2

openSUSE Build Service is sponsored by