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

index 91f1e51b7ff90bd28a11a04d6685361310086a0d..b4bb6ef9a0db53acce19e1de966d2b87f9b749f5 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
-#include <alloca.h>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -67,6 +66,7 @@
 #include "lxcseccomp.h"
 #include "macro.h"
 #include "mainloop.h"
+#include "memory_utils.h"
 #include "monitor.h"
 #include "namespace.h"
 #include "network.h"
@@ -97,16 +97,13 @@ static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
 
 static void print_top_failing_dir(const char *path)
 {
+       __do_free char *copy;
        int ret;
-       size_t len;
-       char *copy, *e, *p, saved;
-
-       len = strlen(path);
-       copy = alloca(len + 1);
-       (void)strlcpy(copy, path, len + 1);
+       char *e, *p, saved;
 
+       copy = must_copy_string(path);
        p = copy;
-       e = copy + len;
+       e = copy + strlen(path);
 
        while (p < e) {
                while (p < e && *p == '/')