From 68336a66df175c8f59e49ded276f95073326bfcd Mon Sep 17 00:00:00 2001 From: liuhao Date: Tue, 18 Jun 2019 23:16:09 +0800 Subject: [PATCH 108/140] check calloc input valid check calloc input valid Signed-off-by: liuhao Signed-off-by: LiFeng --- 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