mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-26 05:55:35 +00:00
terminal: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
97f35ce6f8
commit
2530ba9597
@ -44,6 +44,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "lxclock.h"
|
#include "lxclock.h"
|
||||||
#include "mainloop.h"
|
#include "mainloop.h"
|
||||||
|
#include "memory_utils.h"
|
||||||
#include "start.h"
|
#include "start.h"
|
||||||
#include "syscall_wrappers.h"
|
#include "syscall_wrappers.h"
|
||||||
#include "terminal.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)
|
static int lxc_terminal_rotate_log_file(struct lxc_terminal *terminal)
|
||||||
{
|
{
|
||||||
|
__do_free char *tmp = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
if (!terminal->log_path || terminal->log_rotate == 0)
|
if (!terminal->log_path || terminal->log_rotate == 0)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -211,7 +212,7 @@ static int lxc_terminal_rotate_log_file(struct lxc_terminal *terminal)
|
|||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
len = strlen(terminal->log_path) + sizeof(".1");
|
len = strlen(terminal->log_path) + sizeof(".1");
|
||||||
tmp = alloca(len);
|
tmp = must_realloc(NULL, len);
|
||||||
|
|
||||||
ret = snprintf(tmp, len, "%s.1", terminal->log_path);
|
ret = snprintf(tmp, len, "%s.1", terminal->log_path);
|
||||||
if (ret < 0 || (size_t)ret >= len)
|
if (ret < 0 || (size_t)ret >= len)
|
||||||
|
Loading…
Reference in New Issue
Block a user