Skip to content

fix: leftover CLI atoi - #1

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:fix/leftover-cli-atoi
Open

tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:fix/leftover-cli-atoi

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

InitOptionsFuncTab parses untrusted updater CLI / misc tokens --retry_count, --panic_count, and --upgraded_pkg_num with atoi. Overflow is undefined behavior and can abort; empty/garbage becomes 0 (retry treated as first boot; pkgLocation wraps when a negative atoi result is cast to unsigned int).

Parse via std::from_chars (ParseCliNumber). Valid integers keep the same result; reject overflow/partial/empty and log with LOG(ERROR).

Test plan

  • Host+ASan/UBSan: /workspace/test_parse_cli_number — valid 0/1/8/INT_MAX/INT_MIN/UINT_MAX parse; overflow, empty, mixed, non-digits, and unsigned-negative rejected with no sanitizer reports.

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

Parse retry_count, panic_count, and upgraded_pkg_num from untrusted
updater CLI/misc with std::from_chars instead of atoi so overflow,
empty, and partial tokens are rejected instead of aborting.

Signed-off-by: Tony Coder <407243179@qq.com>
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