Files
harfbuzz/test/shape/data
Behdad EsfahbodandClaude Opus 4.8 ec4a38c4ab [aat] Fix negative-state arithmetic in StateTable so 'kern'/'mort'
tables with a non-first initial state are accepted

AAT::StateTable numbers the rows before the initial 'kern'/'mort'
row negatively (the Apple stateArray quirk the code documents), but
the negative branch of sanitize() passed the negative int min_state
to hb_unsigned_mul_overflows() and used it in unsigned index
arithmetic, so the overflow check always fired and such tables were
always rejected and silently dropped.  get_entry() indexed the state
array the same unsigned way and would read far past it had sanitize()
let those tables through, so the two functions have to be fixed
together.

sanitize() now works with the magnitude of min_state
(num_neg_states = -min_state) for the overflow check, the
check_range() and the sweep pointer, and get_entry() computes its row
index in signed int so negative states address the rows before the
initial one.  Negative states only arise for ObsoleteTypes, where
nClasses and offsets are 16-bit so the products fit; for ExtendedTypes
states are never negative and sanitize() already bounds
(max_state+1)*nClasses by the blob size, so the (int) casts cannot
change any sanitized index.

Fonts whose 'kern' format 1 / 'mort' state tables use a non-first
initial state now sanitize and apply instead of being dropped.  Adds
a regression test (kern-format1.tests plus its font) to
test/shape/data/in-house.

Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-FM7UTB3Y.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-02 10:51:40 -06:00
..