Skip to content

fix: leftover ExtractFd stoi abort on oversized fd:// - #1

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:cursor/extract-fd-stoi-leftover
Open

fix: leftover ExtractFd stoi abort on oversized fd://#1
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:cursor/extract-fd-stoi-leftover

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

SystemSoundVibrator::ExtractFd already rejects a fd:// suffix that is not all digits, then still calls std::stoi. A digit-only string that does not fit in int (2147483648, 9999999999999999999) throws std::out_of_range and aborts the process.

Parse with strtol and reject empty / non-digits / ERANGE / out-of-int / negative. Same leftover class as other OH property/stoi guards.

Test plan

  • Host leftover test (g++ -fsanitize=address,undefined): legacy stoi throws on oversized fd://; strtol path returns -1 and accepts 0 / 3 / INT_MAX.
  • Maintainer CI on this PR.

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

ExtractFd digit-checks fd:// then calls std::stoi. A long digit
string still throws std::out_of_range and aborts. Parse with
strtol and reject ERANGE / out-of-int / non-digits.

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