nsh: Fix a potential buffer overflow in cmd help

Follow https://github.com/apache/nuttx-apps/pull/1621, fix issue of builtin command list.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2023-03-08 20:56:16 +08:00 committed by Xiang Xiao
parent dd2c3b3f6a
commit dbf7d34a2a

View File

@ -813,7 +813,11 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
unsigned int j;
unsigned int k;
unsigned int offset;
char line[HELP_LINELEN];
/* Extra 5 bytes for tab before newline and '\0' */
char line[HELP_LINELEN + HELP_TABSIZE + 1];
static const char *g_builtin_prompt = "\nBuiltin Apps:\n";
/* Count the number of built-in commands and get the optimal column width */