Explorar o código

Merge pull request #4720 from geniusgogo/fix_shell

fix shell msh_exec memory over-bound.
Bernard Xiong %!s(int64=4) %!d(string=hai) anos
pai
achega
e614100084
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      components/finsh/msh.c

+ 1 - 1
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--;