Zepp-Hanzj opened a new pull request, #3523:
URL: https://github.com/apache/nuttx-apps/pull/3523
## Description
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 #3513
## Changes
- `system/nxinit/parser.c`: Add empty/whitespace-only line skip logic in
`init_parse_config_file()`
## Testing
Verified on `sim:nsh` with NXINIT enabled and an init.rc containing empty
lines:
```
on boot
start console
sleep 1
← empty line (previously caused -EINVAL)
service console sh
class core
restart_period 1000
```
**Before fix:**
```
Error Parse /etc/init.d/init.rc -22
```
**After fix:**
```
nsh> ps
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK
STACK COMMAND
4 4 0 100 FIFO Task - Waiting Signal
0000000000000000 0067496 init_main
5 5 4 100 FIFO Task - Running
0000000000000000 0067504 sh
6 6 4 100 FIFO Task - Ready
0000000000000000 0067464 system -c sleep 1
```
NXInit successfully parsed the init.rc with empty lines and started the
console service.
Signed-off-by: hanzj-mi <[email protected]>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]