Skip to content

fix: leftover spawn timeout atoi - #1

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:leftover-spawn-timeout-atoi
Open

tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:leftover-spawn-timeout-atoi

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

GetSpawnTimeout reads a system parameter and converts it with atoi. atoi does not set errno on overflow or invalid input, so the existing errno check is dead. Negative or garbage parameter strings wrap when cast to uint32_t.

Add ParseSpawnTimeoutU32 (strtoul) and use it in GetSpawnTimeout:

  • reject empty input, no digits, trailing junk, ERANGE, and values above UINT32_MAX
  • on parse failure, keep def
  • if the parsed value is below def, keep def (same min-vs-default behavior as before)

Test plan

  • Host+asan/ubsan parser tests: valid numbers, empty, junk, overflow, negative
  • No change to CompareVersion / ace_adapter / sandbox PARENT_UID

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

GetSpawnTimeout uses atoi on a system-parameter string. atoi does not set
errno on overflow or invalid input, so the errno check is dead. Negative
or garbage values wrap when cast to uint32_t.
Parse with strtoul via ParseSpawnTimeoutU32 and keep the default timeout
on junk, overflow, or a value below the caller default.

Signed-off-by: Tony Coder <407243179@qq.com>
@tonycoder-hub
tonycoder-hub force-pushed the leftover-spawn-timeout-atoi branch from 86cb27b to 68c21ab Compare August 31, 2026 03:43
@OpenHarmonySCM-noreply
OpenHarmonySCM-noreply force-pushed the master branch 2 times, most recently from 660f1a3 to f296249 Compare September 9, 2026 22:40
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