shell: Fix potential overwrite when using strncpy

Size argument must be smaller than strTo buffer size since
strncpy terminates string with NULL.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2019-11-21 12:51:53 +01:00 committed by Ioannis Glaropoulos
commit 6b31d67c6d

View file

@ -440,7 +440,7 @@ static u16_t common_beginning_find(const struct shell *shell,
shell_cmd_get(shell, cmd ? cmd->subcmd : NULL, cmd ? 1 : 0,
first, &match, &dynamic_entry);
strncpy(shell->ctx->temp_buff, match->syntax,
sizeof(shell->ctx->temp_buff));
sizeof(shell->ctx->temp_buff) - 1);
*str = match->syntax;