mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
MarkBasePosFormat1 and MarkLigPosFormat1 find a mark's base with a cache (c->last_base / last_base_until) that is only amortized while buffer->idx moves forward. A (Chain)Context lookup that recurses into the mark lookup at input positions out of order resets the cache, so each application rescans the glyphs from last_base_until to idx from scratch; on a long run of marks with no base this is quadratic and was uncharged. Charge the rescanned span (idx - j) to buffer->max_ops after the backward search in both lookups, failing the shape when the budget runs out. A real mark-heavy font pays a negligible amount. Adds a regression test shaping a Context lookup that recurses to MarkBasePos at positions 1,0,1,0,... Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-FJEXEDJ4. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>