From: Christian Brauner Date: Tue, 5 Feb 2019 06:01:50 +0000 (+0100) Subject: lxc_user_nic: remove stack allocations X-Git-Tag: lxc-3.2.0~164^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa4719e2c96f4e42bf9741cf3dfbb57d26487a67;p=thirdparty%2Flxc.git lxc_user_nic: remove stack allocations Signed-off-by: Christian Brauner --- diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index aa6368840..7d1522bf2 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -368,9 +368,11 @@ lxc_monitord_SOURCES = cmd/lxc_monitord.c \ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \ ../include/netns_ifaddrs.c ../include/netns_ifaddrs.h \ log.c log.h \ + memory_utils.h \ network.c network.h \ parse.c parse.h \ raw_syscalls.c raw_syscalls.h \ + string_utils.c string_utils.h \ syscall_wrappers.h lxc_usernsexec_SOURCES = cmd/lxc_usernsexec.c \ conf.c conf.h \ diff --git a/src/lxc/cmd/lxc_user_nic.c b/src/lxc/cmd/lxc_user_nic.c index bd60228aa..be6b395be 100644 --- a/src/lxc/cmd/lxc_user_nic.c +++ b/src/lxc/cmd/lxc_user_nic.c @@ -49,9 +49,11 @@ #include "config.h" #include "log.h" +#include "memory_utils.h" #include "network.h" #include "parse.h" #include "raw_syscalls.h" +#include "string_utils.h" #include "syscall_wrappers.h" #include "utils.h" @@ -838,13 +840,12 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid, static bool create_db_dir(char *fnam) { - int ret; + __do_free char *copy; char *p; - size_t len; + int ret; - len = strlen(fnam); - p = alloca(len + 1); - (void)strlcpy(p, fnam, len + 1); + copy = must_copy_string(fnam); + p = copy; fnam = p; p = p + 1;