Skip to content

Commit

Permalink
terminal: remove stack allocations
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 6, 2019
1 parent 97f35ce commit 2530ba9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lxc/terminal.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 2530ba9

Please sign in to comment.