mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
system/nxinit: skip empty lines in init.rc parser
Empty lines in init.rc caused parsing to fail with -EINVAL because init_parse_arguments() returns 0 for empty strings, triggering the 'argc < 1' error path in init_action_parse() and accessing uninitialized argv[0] in init_service_parse(). Fix by skipping empty lines and lines containing only whitespace before attempting to match section keywords or calling parser callbacks. Fixes apache/nuttx-apps#3513 Signed-off-by: hanzj <hanzhijian@zepp.com>
This commit is contained in:
parent
c106a02b58
commit
8393a2ba1c
1 changed files with 10 additions and 0 deletions
|
|
@ -179,6 +179,16 @@ int init_parse_config_file(FAR const struct parser_s *parser,
|
|||
n -= nl - buf;
|
||||
init_debug("Line %3d: '%s'", ++line, buf);
|
||||
|
||||
/* Skip empty lines and lines containing only whitespace */
|
||||
|
||||
for (ret = 0; buf[ret] && isblank(buf[ret]); ret++);
|
||||
|
||||
if (buf[ret] == '\0')
|
||||
{
|
||||
memmove(buf, nl, n);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ret = 0; parser[ret].key; ret++)
|
||||
{
|
||||
if (!strncmp(parser[ret].key, buf, strlen(parser[ret].key)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue