Skip to content

fix(ans): reject invalid setRecentCount dump arg via from_chars - #1

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:fix-set-recent-count-atoi
Open

fix(ans): reject invalid setRecentCount dump arg via from_chars#1
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:fix-set-recent-count-atoi

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

ShellDump setRecentCount (AdvancedNotificationService::SetRecentNotificationCount) used bare atoi on the dump argument before checking [NOTIFICATION_MIN_COUNT, NOTIFICATION_MAX_COUNT] (0..1024).

atoi("abc") / atoi("") become 0 (in range) and are silently accepted; atoi("12xyz") truncates to 12. This PR parses with digits-only std::from_chars and rejects empty, non-digit, partial, and out-of-range values.

Changes

  • Add services/ans/include/parse_recent_notification_count.h with ParseRecentNotificationCount (match miscservices_request parse helper style).
  • Use it in SetRecentNotificationCount; drop the separate min/max if-check (parser already enforces [0, 1024]).

Testing

  • No device needed (dump-path parse hardening only).
  • Host review of digits-only / from_chars / bounds logic.

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

ShellDump setRecentCount used bare atoi, so non-numeric and
partial inputs could become 0 (in-range) or a truncated value.
Parse with digits-only from_chars and enforce [0,1024].

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