Skip to content

Commit 0ce966b

Browse files
Jakub Rzeszutkocarlescufi
authored andcommitted
subsys: shell: manual * parsing
This PR fixes: #10195. Function _vprintk when used cannot parse '*' what a as result causes dereferencing bad pointer. Signed-off-by: Jakub Rzeszutko <[email protected]>
1 parent d6e0fdc commit 0ce966b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

subsys/shell/shell.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,11 +1533,23 @@ static void help_item_print(const struct shell *shell, const char *item_name,
15331533
return;
15341534
}
15351535

1536-
/* print option name */
1537-
shell_fprintf(shell, SHELL_NORMAL, "%s%-*s%s:",
1538-
tabulator,
1539-
item_name_width, item_name,
1540-
tabulator);
1536+
if (!IS_ENABLED(CONFIG_NEWLIB_LIBC) && !IS_ENABLED(CONFIG_ARCH_POSIX)) {
1537+
/* print option name */
1538+
shell_fprintf(shell, SHELL_NORMAL, "%s%-*s%s:",
1539+
tabulator,
1540+
item_name_width, item_name,
1541+
tabulator);
1542+
} else {
1543+
u16_t tmp = item_name_width - strlen(item_name);
1544+
char space = ' ';
1545+
1546+
shell_fprintf(shell, SHELL_NORMAL, "%s%s", tabulator,
1547+
item_name);
1548+
for (u16_t i = 0; i < tmp; i++) {
1549+
shell_write(shell, &space, 1);
1550+
}
1551+
shell_fprintf(shell, SHELL_NORMAL, "%s:", tabulator);
1552+
}
15411553

15421554
if (item_help == NULL) {
15431555
cursor_next_line_move(shell);

0 commit comments

Comments
 (0)