mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
system/nxinit: prevent parser from reading past string boundry
Any string ending with whitespace passed to init_parse_arguments() could cause the parser to advance past the string boundary and read unintended memory content. - " echo "A" \0& echo "B" should be parsed as a command with two argvs instand of five. - "command arg " may lead to uncertain results. Signed-off-by: fangpeina <fangpeina@xiaomi.com>
This commit is contained in:
parent
4f9c20a3db
commit
ea57dbd121
1 changed files with 6 additions and 1 deletions
|
|
@ -46,7 +46,7 @@ int init_parse_arguments(FAR char *buf, bool dup, int argc, FAR char **argv)
|
|||
bool new = true;
|
||||
int i = 0;
|
||||
|
||||
while (*buf != '\0')
|
||||
for (; ; )
|
||||
{
|
||||
while (isblank(*buf))
|
||||
{
|
||||
|
|
@ -91,6 +91,11 @@ int init_parse_arguments(FAR char *buf, bool dup, int argc, FAR char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (*buf == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (new)
|
||||
{
|
||||
argv[i++] = buf;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue