shell: fix select command

If the command buffer is empty the shell was trying to read a string
from a random memory location. Added a condition checking "argc" value
when the select command is executed.

Fixes: #27227

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
This commit is contained in:
Jakub Rzeszutko 2020-07-29 11:46:33 +02:00 committed by Carles Cufí
commit e76cd05e18

View file

@ -236,7 +236,7 @@ static bool tab_prepare(const struct shell *shell,
(void)shell_make_argv(argc, *argv, shell->ctx->temp_buff,
CONFIG_SHELL_ARGC_MAX);
if (IS_ENABLED(CONFIG_SHELL_CMDS_SELECT) &&
if (IS_ENABLED(CONFIG_SHELL_CMDS_SELECT) && (*argc > 0) &&
(strcmp("select", (*argv)[0]) == 0) &&
!shell_in_select_mode(shell)) {
*argv = *argv + 1;