Skip to content

Commit 6198eea

Browse files
szsammysterywolf
authored andcommitted
[msh] fix offset used before range check
These uses of offset 'cmd0_size' should follow the range check.
1 parent 177f3d4 commit 6198eea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

components/finsh/msh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
274274
RT_ASSERT(retp);
275275

276276
/* find the size of first command */
277-
while ((cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t') && cmd0_size < length)
277+
while (cmd0_size < length && (cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t'))
278278
cmd0_size ++;
279279
if (cmd0_size == 0)
280280
return -RT_ERROR;

0 commit comments

Comments
 (0)