]> git.proxmox.com Git - mirror_lxc.git/commitdiff
conf: do not deref null pointer
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 26 Aug 2017 22:48:34 +0000 (00:48 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 27 Aug 2017 15:51:23 +0000 (17:51 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 26cb42ab19dea0ab149fe5998de409c0fa06b7c8..6171a017c7827690f3bf26534b8e6dfb402e3fc4 100644 (file)
@@ -3324,11 +3324,17 @@ static int unpriv_assign_nic(const char *lxcpath, char *lxcname,
                        exit(EXIT_FAILURE);
                pidstr[LXC_NUMSTRLEN64 - 1] = '\0';
 
-               INFO("Execing lxc-user-nic %s %s %s veth %s %s", lxcpath,
-                    lxcname, pidstr, netdev_link, netdev->name);
-               execlp(LXC_USERNIC_PATH, LXC_USERNIC_PATH, lxcpath, lxcname,
-                      pidstr, "veth", netdev_link, netdev->name, NULL);
-
+               INFO("Execing lxc-user-nic create %s %s %s veth %s %s", lxcpath,
+                    lxcname, pidstr, netdev_link,
+                    netdev->name ? netdev->name : "(null)");
+               if (netdev->name)
+                       execlp(LXC_USERNIC_PATH, LXC_USERNIC_PATH, "create",
+                              lxcpath, lxcname, pidstr, "veth", netdev_link,
+                              netdev->name, (char *)NULL);
+               else
+                       execlp(LXC_USERNIC_PATH, LXC_USERNIC_PATH, "create",
+                              lxcpath, lxcname, pidstr, "veth", netdev_link,
+                              (char *)NULL);
                SYSERROR("Failed to exec lxc-user-nic.");
                exit(EXIT_FAILURE);
        }