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:
hanzj 2026-06-04 14:18:10 +08:00 committed by Alan C. Assis
parent 840c2f30db
commit e86c0b997d

View file

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