[libvirt] [PATCH 2/2] xenParseXM: don't dereference NULL pointer when script is empty

Guido Günther agx at sigxcpu.org
Thu Oct 6 09:16:50 UTC 2011


O.k. to apply?
 -- Guido

---
 src/xenxs/xen_xm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index d057043..30188e2 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -697,8 +697,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
                 }
             }
 
-            if (bridge[0] || STREQ(script, "vif-bridge") ||
-                STREQ(script, "vif-vnic")) {
+            if (bridge[0] || (script && (STREQ(script, "vif-bridge") ||
+                STREQ(script, "vif-vnic")))) {
                 net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
             } else {
                 net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
@@ -715,7 +715,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
                     !(net->data.bridge.ipaddr = strdup(ip)))
                     goto no_memory;
             } else {
-                if (script[0] &&
+                if (script && script[0] &&
                     !(net->data.ethernet.script = strdup(script)))
                     goto no_memory;
                 if (ip[0] &&
-- 
1.7.6.3




More information about the libvir-list mailing list