From: Christian Brauner Date: Tue, 5 Feb 2019 06:06:02 +0000 (+0100) Subject: commands_utils: remove stack allocations X-Git-Tag: lxc-3.2.0~164^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdcdb6542b2513197031f7a755044741d16713a5;p=thirdparty%2Flxc.git commands_utils: remove stack allocations Signed-off-by: Christian Brauner --- diff --git a/src/lxc/commands_utils.c b/src/lxc/commands_utils.c index f48f1188c..5545744b6 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");