From 6010bd3e126717ef8e16a83d5b489aea42de889d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 23 Aug 2021 18:01:28 +0100 Subject: [PATCH] utils: make sure read() string is 0 terminated Coverity CID: 1490062 String not null terminated Signed-off-by: Daniel Golle --- utils/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/utils.c b/utils/utils.c index e90feec..2cfcc8e 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -140,6 +140,7 @@ char *get_active_console(char *out, int len) char line[CMDLINE_SIZE + 1]; int fd = open("/sys/class/tty/console/active", O_RDONLY); ssize_t r = read(fd, line, sizeof(line) - 1); + line[CMDLINE_SIZE] = '\0'; close(fd); -- 2.30.2