[lxc-devel] [lxc/master] lxc_execute: properly figure out number of needed arguments

hallyn on Github lxc-bot at linuxcontainers.org
Tue Dec 5 04:32:47 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 615 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171205/5683c533/attachment.bin>
-------------- next part --------------
From 858faf70ab8d73232a07d49131a442cf954a4e00 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <shallyn at cisco.com>
Date: Mon, 4 Dec 2017 22:30:26 -0600
Subject: [PATCH] lxc_execute: properly figure out number of needed arguments

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 at cisco.com>
---
 src/lxc/execute.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/lxc/execute.c b/src/lxc/execute.c
index 2f7f13747..1b142aeca 100644
--- a/src/lxc/execute.c
+++ b/src/lxc/execute.c
@@ -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)


More information about the lxc-devel mailing list