[Pkg-libvirt-maintainers] Bug#769600: Acknowledgement (libvirt-daemon - null pointer deref in libvirt_lxc)

Bastian Blank waldi at debian.org
Sat Nov 15 14:51:45 UTC 2014


Control: tag -1 patch

I attached a possible patch to fix both the check and the actual setup.

Bastian

-- 
The heart is not a logical organ.
		-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
-------------- next part --------------
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index db823d6..1db33ea 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -472,7 +472,7 @@ lxcContainerGetNetDef(virDomainDefPtr vmDef, const char *devName)
 
     for (i = 0; i < vmDef->nnets; i++) {
         netDef = vmDef->nets[i];
-        if (STREQ(netDef->ifname_guest_actual, devName))
+        if (netDef->ifname_guest_actual && STREQ(netDef->ifname_guest_actual, devName))
             return netDef;
     }
 
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 37ddbbc..ac086d0 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -259,8 +259,6 @@ char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
 
     if (virNetDevSetMAC(containerVeth, &net->mac) < 0)
         goto cleanup;
-    if (VIR_STRDUP(net->ifname_guest_actual, containerVeth) < 0)
-        goto cleanup;
 
     if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
         if (virNetDevOpenvswitchAddPort(brname, parentVeth, &net->mac,
@@ -452,6 +450,10 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
 
         (*veths)[(*nveths)-1] = veth;
 
+        if (VIR_STRDUP(def->nets[i]->ifname_guest_actual, veth) < 0)
+            /* XXX: No error handling! */
+            return -1;
+
         /* Make sure all net definitions will have a name in the container */
         if (!def->nets[i]->ifname_guest) {
             if (virAsprintf(&def->nets[i]->ifname_guest, "eth%zu", niface) < 0)


More information about the Pkg-libvirt-maintainers mailing list