From c8a0e25a5214b7c1a7593abfe89c1e1d5c013d07 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 5 Feb 2019 07:06:02 +0100 Subject: [PATCH] commands_utils: remove stack allocations Signed-off-by: Christian Brauner --- src/lxc/commands_utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lxc/commands_utils.c b/src/lxc/commands_utils.c index f48f1188c5..5545744b6e 100644 --- a/src/lxc/commands_utils.c +++ b/src/lxc/commands_utils.c @@ -38,6 +38,7 @@ #include "initutils.h" #include "log.h" #include "lxclock.h" +#include "memory_utils.h" #include "monitor.h" #include "state.h" #include "utils.h" @@ -102,9 +103,9 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen, const char *hashed_sock_name, const char *suffix) { + __do_free char *tmppath = NULL; const char *name; char *offset; - char *tmppath; size_t len; size_t tmplen; uint64_t hash; @@ -153,7 +154,7 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen, /* ret >= len; lxcpath or name is too long. hash both */ tmplen = strlen(name) + strlen(lxcpath) + 2; - tmppath = alloca(tmplen); + tmppath = must_realloc(NULL, tmplen); ret = snprintf(tmppath, tmplen, "%s/%s", lxcpath, name); if (ret < 0 || (size_t)ret >= tmplen) { ERROR("Failed to create abstract socket name");