uart: native_posix: Fix out of bounds access

Fix an out of bound access in the native_posix uart driver,
when generating the string to autoattach a terminal to the UART.
(The space for the null termination was missing)

Fixes: #14401
Coverity issue CID: 195855

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2019-03-13 11:54:47 +01:00 committed by Kumar Gala
parent 448755e622
commit 319caa25e0

View file

@ -65,7 +65,7 @@ static void attach_to_tty(const char *slave_tty)
if (auto_attach_cmd == NULL) {
auto_attach_cmd = (char *)default_cmd;
}
char command[strlen(auto_attach_cmd) + strlen(slave_tty)];
char command[strlen(auto_attach_cmd) + strlen(slave_tty) + 1];
sprintf(command, auto_attach_cmd, slave_tty);