Skip to content

ICU-23334 Fix plurrule_fuzzer: clamp UPluralType enum and add NULL check#3933

Open
OwenSanzas wants to merge 1 commit intounicode-org:mainfrom
OwenSanzas:fix-plurrule-fuzzer
Open

ICU-23334 Fix plurrule_fuzzer: clamp UPluralType enum and add NULL check#3933
OwenSanzas wants to merge 1 commit intounicode-org:mainfrom
OwenSanzas:fix-plurrule-fuzzer

Conversation

@OwenSanzas
Copy link
Copy Markdown

Summary

  • Invalid enum values: UPluralType type is read directly from fuzz data via memcpy, allowing arbitrary integer values. Only 0 (CARDINAL) and 1 (ORDINAL) are valid — passing other values to PluralRules::forLocale() is undefined behavior. Fix: clamp with % 2 after reading.
  • NULL check: Add nullptr guard in TestPluralRules before calling pp->select(), matching the defensive pattern in other ICU fuzzers.
  • Deprecated API: Replace UPLURAL_TYPE_COUNT (deprecated) with explicit 2.

Coverage

60-second LibFuzzer run, empty seed corpus, ASan instrumentation:

Metric Original Fixed Change
Edge coverage 2327 2695 +15.81% (+368)
Feature coverage 8057 9033 +12.11% (+976)

Both original and fixed fuzzers run clean (no crashes).

1. Clamp UPluralType to valid values (0=CARDINAL, 1=ORDINAL) before
   passing to PluralRules::forLocale(). Raw fuzz bytes can produce
   arbitrary enum values which is undefined behavior.

2. Add nullptr check in TestPluralRules before calling pp->select()
   to guard against edge cases where forLocale returns NULL with
   U_ZERO_ERROR status.

3. Replace deprecated UPLURAL_TYPE_COUNT with explicit value 2.

Coverage: +15.81% edge coverage (+368 edges) in 60s run.
@markusicu markusicu self-assigned this Apr 9, 2026
@markusicu markusicu requested a review from FrankYFTang April 9, 2026 16:32
@OwenSanzas OwenSanzas changed the title Fix plurrule_fuzzer: clamp UPluralType enum and add NULL check ICU-23334 Fix plurrule_fuzzer: clamp UPluralType enum and add NULL check Apr 9, 2026
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.

2 participants