[lxc-devel] [PATCH] Ensure argv passed by createl to create is NULL terminated

Dwight Engen dwight.engen at oracle.com
Mon Nov 26 17:18:13 UTC 2012


Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 src/lxc/lxccontainer.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 37f5ed7..4818b2c 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -683,13 +683,14 @@ static bool lxcapi_createl(struct lxc_container *c, char *t, ...)
 		if (!arg)
 			break;
 		nargs++;
-		temp = realloc(args, nargs * sizeof(*args));
+		temp = realloc(args, (nargs+1) * sizeof(*args));
 		if (!temp)
 			goto out;
 		args = temp;
 		args[nargs - 1] = arg;
 	}
 	va_end(ap);
+	args[nargs] = NULL;
 
 	bret = c->create(c, t, args);
 
-- 
1.7.1





More information about the lxc-devel mailing list