aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Santos <michael.santos@gmail.com>2011-03-19 11:11:03 -0400
committerDaniel Lezcano <dlezcano@fr.ibm.com>2011-03-22 15:04:52 +0100
commit95642a106820def0499d7aa24baa0d119d998700 (patch)
tree52504c1a1dc32a5bc255e1af6e5e95f2edb84790 /src
parentarguments: check allocation succeeds (diff)
downloadlxc-95642a106820def0499d7aa24baa0d119d998700.tar.gz
lxc-95642a106820def0499d7aa24baa0d119d998700.tar.bz2
lxc-95642a106820def0499d7aa24baa0d119d998700.zip
conf: increase buffer size to include spaces
Signed-off-by: Michael Santos <michael.santos@gmail.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/lxc/conf.c8
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;