Caption numeric setters cast negative floats to unsigned int (UBSan) #309
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#309
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by:
fuzz_property_typestarget (W5)Summary
src/UICaption.cpp:216casts a rawfloattounsigned intwithout clamping or range-checking. Feeding a negative value (e.g.-992.065) into one of the Caption numeric setters (outline,font_size, orz_index) produces undefined behavior. UBSan reports:Reproduction
Crash input preserved at:
Root Cause
The setter accepts a Python float and casts it directly:
Any value
< 0or> UINT_MAXis UB on the cast.Suggested Fix
Clamp to the valid range before the cast, e.g.:
or change the underlying storage to a signed type if negatives are meaningful (they almost certainly aren't for
outline/font_size).Scope
Audit the other numeric setters on
UICaption(and likely other UI types) for the same pattern while we're in there.