]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
terminal: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:26:19 +0000 (07:26 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Feb 2019 10:47:58 +0000 (11:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/terminal.c

index de00891018a7b5e7ab53023a262dfa03e6fdb735..4ea0c5dc3c551d42a9593053445e397a20c31a2c 100644 (file)
@@ -44,6 +44,7 @@
 #include "log.h"
 #include "lxclock.h"
 #include "mainloop.h"
+#include "memory_utils.h"
 #include "start.h"
 #include "syscall_wrappers.h"
 #include "terminal.h"
@@ -199,9 +200,9 @@ static int lxc_terminal_truncate_log_file(struct lxc_terminal *terminal)
 
 static int lxc_terminal_rotate_log_file(struct lxc_terminal *terminal)
 {
+       __do_free char *tmp = NULL;
        int ret;
        size_t len;
-       char *tmp;
 
        if (!terminal->log_path || terminal->log_rotate == 0)
                return -EOPNOTSUPP;
@@ -211,7 +212,7 @@ static int lxc_terminal_rotate_log_file(struct lxc_terminal *terminal)
                return -EBADF;
 
        len = strlen(terminal->log_path) + sizeof(".1");
-       tmp = alloca(len);
+       tmp = must_realloc(NULL, len);
 
        ret = snprintf(tmp, len, "%s.1", terminal->log_path);
        if (ret < 0 || (size_t)ret >= len)