lxc/0131-fix-commands-and-terminal-memory-leak-bug.patch

44 lines
1.4 KiB
Diff
Raw Normal View History

From 720f6f1c128eaac5c37153cdc30f09e4b18785aa Mon Sep 17 00:00:00 2001
2019-12-25 15:57:42 +08:00
From: wujing <wujing50@huawei.com>
Date: Wed, 18 Dec 2019 15:44:19 +0800
Subject: [PATCH 131/140] fix commands and terminal memory leak bug
2019-12-25 15:57:42 +08:00
Signed-off-by: wujing <wujing50@huawei.com>
---
src/lxc/commands.c | 5 ++++-
src/lxc/terminal.c | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index 7d6cf6f..b70564f 100644
2019-12-25 15:57:42 +08:00
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -1083,8 +1083,11 @@ int lxc_cmd_set_terminal_fifos(const char *name, const char *lxcpath, const char
if (tmp == NULL)
return -1;
ret = snprintf(tmp, len, "%s%s%s%s%s", cmd_in_fifo, split, cmd_out_fifo, split, cmd_err_fifo);
- if (ret < 0 || ret >= len)
+ if (ret < 0 || ret >= len) {
+ ERROR("Failed to snprintf in fifo of command");
+ free(tmp);
return -1;
+ }
struct lxc_cmd_rr cmd = {
.req = {
diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c
index b547013..bccc23d 100644
2019-12-25 15:57:42 +08:00
--- a/src/lxc/terminal.c
+++ b/src/lxc/terminal.c
@@ -243,6 +243,7 @@ static int lxc_terminal_rename_old_log_file(struct lxc_terminal *terminal)
for (i = terminal->log_rotate - 1; i > 1; i--) {
ret = snprintf(tmp, PATH_MAX, "%s.%u", terminal->log_path, i);
if (ret < 0 || ret >= PATH_MAX) {
+ free(rename_fname);
return -EFBIG;
}
free(rename_fname);
--
1.8.3.1
2019-12-25 15:57:42 +08:00