[lxc-devel] [PATCH 4/5] conf: increase buffer size to include spaces

Michael Santos michael.santos at gmail.com
Sat Mar 19 15:11:03 UTC 2011


Signed-off-by: Michael Santos <michael.santos at gmail.com>
---
 src/lxc/conf.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index f73eaac..ae5b259 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -205,14 +205,18 @@ static int run_script(const char *name, const char *section,
 
 	va_start(ap, script);
 	while ((p = va_arg(ap, char *)))
-		size += strlen(p);
+		size += strlen(p) + 1;
 	va_end(ap);
 
 	size += strlen(script);
 	size += strlen(name);
 	size += strlen(section);
+	size += 3;
 
-	buffer = alloca(size + 1);
+	if (size > INT_MAX)
+		return -1;
+
+	buffer = alloca(size);
 	if (!buffer) {
 		ERROR("failed to allocate memory");
 		return -1;
-- 
1.7.0.4





More information about the lxc-devel mailing list