Skip to content

Commit 6b31d67

Browse files
nordic-krchioannisg
authored andcommitted
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 <[email protected]>
1 parent 113b80f commit 6b31d67

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/shell/shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static u16_t common_beginning_find(const struct shell *shell,
440440
shell_cmd_get(shell, cmd ? cmd->subcmd : NULL, cmd ? 1 : 0,
441441
first, &match, &dynamic_entry);
442442
strncpy(shell->ctx->temp_buff, match->syntax,
443-
sizeof(shell->ctx->temp_buff));
443+
sizeof(shell->ctx->temp_buff) - 1);
444444

445445
*str = match->syntax;
446446

0 commit comments

Comments
 (0)