Skip to content

fix: leftover follow-x mode atoi - #1

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:leftover-followx-mode-atoi
Open

fix: leftover follow-x mode atoi#1
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:leftover-followx-mode-atoi

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

GetFollowXRule reads CUST_FOLLOW_X_RULES system-parameter segments and converts the mode field with atoi. atoi does not reject trailing junk ("10abc" → 10) or overflow, so a malformed parameter can select the wrong follow-x mode.

Add ParseFollowXMode (strtol with end check) and use it in GetFollowXRule:

  • accept a full decimal mode, or a mode followed by ,extra (USER_DEFINED extra path)
  • reject empty input, signs, spaces, other trailing junk, and overflow
  • on parse failure, keep the caller’s default mode (FOLLOWX_MODE_DEFAULT)

Test plan

  • Host+asan/ubsan parser tests: valid modes 0/1/10/11/12/100, 100,extra/path, empty, signs, spaces, junk, overflow
  • No change to non-follow-x config policy paths

Signed-off-by: Tony Coder 407243179@qq.com

GetFollowXRule parses CUST_FOLLOW_X_RULES mode with atoi. atoi does not
reject trailing junk ("10abc" -> 10) or overflow, so a malformed system
parameter can select the wrong follow-x mode.
Parse with strtol via ParseFollowXMode (allow trailing ',' for the
USER_DEFINED extra path) and keep the caller's default mode on failure.

Signed-off-by: Tony Coder <407243179@qq.com>
@OpenHarmonySCM-noreply
OpenHarmonySCM-noreply force-pushed the master branch 2 times, most recently from 5f93659 to 47f9d30 Compare September 3, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant