system/nxinit: skip empty lines in init.rc parser#3523
Merged
Conversation
ae3f287 to
27266fe
Compare
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#3513 Signed-off-by: hanzj <hanzhijian@zepp.com>
acassis
approved these changes
Jun 4, 2026
Contributor
|
@jerpelea I think this fix also is important |
xiaoxiang781216
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Empty lines in init.rc caused parsing to fail with
-EINVALbecauseinit_parse_arguments()returns 0 for empty strings, triggering theargc < 1error path ininit_action_parse()and accessing uninitializedargv[0]ininit_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 ininit_parse_config_file()Testing
Verified on
sim:nshwith NXINIT enabled and an init.rc containing empty lines:Before fix:
After fix:
NXInit successfully parsed the init.rc with empty lines and started the console service.