[msh] fix offset used before range check

These uses of offset 'cmd0_size' should follow the range check.
This commit is contained in:
Mingjie Shen 2023-06-13 17:33:37 -04:00 committed by Man, Jianting (Meco)
parent 177f3d4056
commit 6198eea6c7
1 changed files with 1 additions and 1 deletions

View File

@ -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;