Skip to content

fix: leftover inject value stoi abort - #2

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:cursor/fix-inject-value-stoi-leftover
Open

fix: leftover inject value stoi abort#2
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:cursor/fix-inject-value-stoi-leftover

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

InjectionEventDispatch::CheckValue (tools/event_inject) length-caps at 11 then digit-checks and calls std::stoi. Values like 2147483648 / -2147483649 still throw std::out_of_range and can abort event_inject.

A from_chars lambda was already present but unused (and missing a semicolon, so the translation unit does not compile as written). Finish the migration: parse with ParseInjectValue (std::from_chars) like the sibling tools/inject_event InputSendeventCommand::CheckValue, and reject overflow/junk without throwing.

Host test

g++ -std=c++17 -fsanitize=address,undefined -Itools/event_inject/include \
  test/hosttest/parse_inject_value_host_test.cpp -o /tmp/parse_inject_value_host_test
/tmp/parse_inject_value_host_test

Covers INT32 min/max, empty/junk, 2147483648, -2147483649, 11×9. asan/ubsan clean. Also shows bare stoi still throws on those overflow strings.

Test plan

  • Host helper + asan/ubsan
  • Valid inject value 0 / -1 / 2147483647 still accepted
  • Overflow digit strings no longer abort event_inject

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

CheckValue length-caps at 11 then digit-checks and calls stoi; values like
2147483648 still throw and can abort event_inject. A from_chars lambda was
already present but unused (and missing a semicolon). Parse with from_chars
like tools/inject_event and reject overflow/junk.

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