lxc/0108-check-calloc-input-valid.patch
LiFeng 7b470b3cde lxc: internal change at 1.6
Change-Id: I5821dc8a44f724e59cee65e356dfae4fbae04f76
Signed-off-by: LiFeng <lifeng68@huawei.com>
2020-01-05 22:20:49 -05:00

34 lines
970 B
Diff

From b23823f7acf224be1c4e99dbc8959b7adb1bcc11 Mon Sep 17 00:00:00 2001
From: liuhao <liuhao27@huawei.com>
Date: Tue, 18 Jun 2019 23:16:09 +0800
Subject: [PATCH 108/138] check calloc input valid
check calloc input valid
Signed-off-by: liuhao <liuhao27@huawei.com>
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
src/lxc/terminal.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c
index 778a0ab..6b117de 100644
--- a/src/lxc/terminal.c
+++ b/src/lxc/terminal.c
@@ -444,8 +444,11 @@ static ssize_t lxc_logger_write(struct lxc_terminal *terminal, const char *type,
parser_error err = NULL;
struct parser_context ctx = { GEN_OPTIONS_SIMPLIFY | GEN_OPTIONS_NOT_VALIDATE_UTF8, stderr };
+ if (bytes_read < 0 || bytes_read >= INT_MAX) {
+ return -1;
+ }
msg = calloc(sizeof(logger_json_file), 1);
- if (!msg) {
+ if (msg == NULL) {
return -errno;
}
msg->log = calloc(bytes_read, 1);
--
1.8.3.1