This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new e86c0b997 system/nxinit: skip empty lines in init.rc parser
e86c0b997 is described below
commit e86c0b997d3ea4bd6bc339d3f556d1f15e9cbaa0
Author: hanzj <[email protected]>
AuthorDate: Thu Jun 4 14:18:10 2026 +0800
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 <[email protected]>
---
system/nxinit/parser.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/system/nxinit/parser.c b/system/nxinit/parser.c
index 3ffe4a5a6..0c91703f8 100644
--- a/system/nxinit/parser.c
+++ b/system/nxinit/parser.c
@@ -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)))