utils: make sure read() string is 0 terminated
authorDaniel Golle <daniel@makrotopia.org>
Mon, 23 Aug 2021 17:01:28 +0000 (18:01 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 24 Aug 2021 17:31:46 +0000 (18:31 +0100)
Coverity CID: 1490062 String not null terminated

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
utils/utils.c

index e90feecb47f3e555ed67cf79ff907561039d00d7..2cfcc8e10c6c930de9aa02c6d77dad2cb2bcd970 100644 (file)
@@ -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);