From 8393a2ba1cde6844a3d052c4cffa5ea70c330853 Mon Sep 17 00:00:00 2001 From: hanzj Date: Thu, 4 Jun 2026 14:18:10 +0800 Subject: [PATCH] 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 --- system/nxinit/parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/nxinit/parser.c b/system/nxinit/parser.c index 3ffe4a5a6f2..0c91703f8c9 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)))