From b00c15567bc0fedc87f5e31106fadc5fbea1ca54 Mon Sep 17 00:00:00 2001
From: liuhao <liuhao27@huawei.com>
Date: Tue, 18 Jun 2019 23:16:09 +0800
Subject: [PATCH 108/131] 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 778a0abd..6b117de7 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);
-- 
2.23.0

