From 6198eea6c751f2923cb46ad9a05b41e37fde3d3f Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Tue, 13 Jun 2023 17:33:37 -0400 Subject: [PATCH] [msh] fix offset used before range check These uses of offset 'cmd0_size' should follow the range check. --- 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 186ede00e2..691ab55381 100644 --- a/components/finsh/msh.c +++ b/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;