]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc_execute: properly figure out number of needed arguments
authorSerge Hallyn <shallyn@cisco.com>
Tue, 5 Dec 2017 04:30:26 +0000 (22:30 -0600)
committerSerge Hallyn <shallyn@cisco.com>
Tue, 5 Dec 2017 04:30:26 +0000 (22:30 -0600)
The lxc_log args have noghing to do with lxc.rootfs.path, and
we need room for a NULL at end of arguments.

How this bug was hidden for so long I don't know - I can only
trigger it on certain systems under certain conditions, but it's
definately wrong as is.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
src/lxc/execute.c

index 2f7f1374701ce7a3ed1b3c97bbbdc68e11fd9211..1b142aeca6ec28b21872126d11b51e195cf47255 100644 (file)
@@ -49,14 +49,14 @@ static int execute_start(struct lxc_handler *handler, void* data)
 
        while (my_args->argv[argc++]);
 
-       argc_add = 4;
+       /* lxc-init -n name -- [argc] NULL -> 5 */
+       argc_add = 5;
        if (my_args->quiet)
                argc_add++;
-       if (!handler->conf->rootfs.path) {
-               argc_add += 4;
-               if (lxc_log_has_valid_level())
-                       argc_add += 2;
-       }
+       if (!handler->conf->rootfs.path)
+               argc_add += 2;
+       if (lxc_log_has_valid_level())
+               argc_add += 2;
 
        argv = malloc((argc + argc_add) * sizeof(*argv));
        if (!argv)