]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc_user_nic: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:01:50 +0000 (07:01 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Feb 2019 10:47:56 +0000 (11:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/Makefile.am
src/lxc/cmd/lxc_user_nic.c

index aa6368840ef1ead27590ad35d055d5e3025ce1b0..7d1522bf2c4b877d2715b1b428a13b9e5d3d57e0 100644 (file)
@@ -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 \
index bd60228aaf9d00ca903e2f4b8bc1d3c1c9e28d07..be6b395be9293c512c96e004d7b5397bd8f474fd 100644 (file)
 
 #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;