瀏覽代碼

[msh] fix offset used before range check

These uses of offset 'cmd0_size' should follow the range check.
Mingjie Shen 1 年之前
父節點
當前提交
6198eea6c7
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      components/finsh/msh.c

+ 1 - 1
components/finsh/msh.c

@@ -274,7 +274,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
     RT_ASSERT(retp);
 
     /* find the size of first command */
-    while ((cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t') && cmd0_size < length)
+    while (cmd0_size < length && (cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t'))
         cmd0_size ++;
     if (cmd0_size == 0)
         return -RT_ERROR;