render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 07cefaf0d0ab324d95e4e0cc1f75004dec487365 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <07cefaf0d0ab324d95e4e0cc1f75004dec487365.1381871411.git.jdenemar@redhat.com>
43fe83
From: Michal Privoznik <mprivozn@redhat.com>
43fe83
Date: Wed, 2 Oct 2013 11:04:07 +0200
43fe83
Subject: [PATCH] virNetDevBandwidthEqual: Make it more robust
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1014503
43fe83
43fe83
So far the virNetDevBandwidthEqual() expected both ->in and ->out items
43fe83
to be allocated for both @a and @b compared. This is not necessary true
43fe83
for all our code. For instance, running 'update-device' twice over a NIC
43fe83
with the very same XML results in SIGSEGV-ing in this function.
43fe83
43fe83
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
43fe83
(cherry picked from commit ee02fbc8e4a24c1347761ceff2ddb2c108e9611c)
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/util/virnetdevbandwidth.c | 26 ++++++++++++++++++++------
43fe83
 1 file changed, 20 insertions(+), 6 deletions(-)
43fe83
43fe83
diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
43fe83
index 42b0a50..17f4fa3 100644
43fe83
--- a/src/util/virnetdevbandwidth.c
43fe83
+++ b/src/util/virnetdevbandwidth.c
43fe83
@@ -335,16 +335,30 @@ virNetDevBandwidthEqual(virNetDevBandwidthPtr a,
43fe83
         return false;
43fe83
 
43fe83
     /* in */
43fe83
-    if (a->in->average != b->in->average ||
43fe83
-        a->in->peak != b->in->peak ||
43fe83
-        a->in->burst != b->in->burst)
43fe83
+    if (a->in) {
43fe83
+        if (!b->in)
43fe83
+            return false;
43fe83
+
43fe83
+        if (a->in->average != b->in->average ||
43fe83
+            a->in->peak != b->in->peak ||
43fe83
+            a->in->burst != b->in->burst)
43fe83
+            return false;
43fe83
+    } else if (b->in) {
43fe83
         return false;
43fe83
+    }
43fe83
 
43fe83
     /*out*/
43fe83
-    if (a->out->average != b->out->average ||
43fe83
-        a->out->peak != b->out->peak ||
43fe83
-        a->out->burst != b->out->burst)
43fe83
+    if (a->out) {
43fe83
+        if (!b->out)
43fe83
+            return false;
43fe83
+
43fe83
+        if (a->out->average != b->out->average ||
43fe83
+            a->out->peak != b->out->peak ||
43fe83
+            a->out->burst != b->out->burst)
43fe83
+            return false;
43fe83
+    } else if (b->out) {
43fe83
         return false;
43fe83
+    }
43fe83
 
43fe83
     return true;
43fe83
 }
43fe83
-- 
43fe83
1.8.3.2
43fe83