From 6c01083502936185a46ff6d7f8bf2732a68c51cf Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Sat, 22 May 2021 19:50:49 +0800 Subject: [PATCH] fix shell msh_exec memory over-bound. --- components/finsh/msh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 73a5197dcd..ed12219c2e 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -374,7 +374,7 @@ int msh_exec(char *cmd, rt_size_t length) int cmd_ret; /* strim the beginning of command */ - while (*cmd == ' ' || *cmd == '\t') + while ((length > 0) && (*cmd == ' ' || *cmd == '\t')) { cmd++; length--;