Files
harfbuzz/test
Behdad EsfahbodandClaude Opus 4.8 f2b79d995c [subset] Look up each retained glyph's ClipRecord by bsearch in ClipList::subset
ClipList::subset() walked startGlyphID..endGlyphID of every ClipRecord,
which is only O(num_glyphs) overall when the records are sorted and
disjoint.  ClipList::sanitize() checks neither, so R overlapping records
each spanning all glyphs cost R x 65535 iterations: a 332 KB font with
10000 whole-range records took about 20 s of CPU in hb-subset whatever
glyphs or text the request asked for.

Invert the loop: iterate the retained glyph set once and find each
glyph's record with clips.as_array ().bsearch (gid), exactly how
ClipList::get_extents() resolves a glyph's clip box when rendering, and
the same shape as the COLRv0 path in COLR::subset().  Cost is now
O(|glyphset| log R) regardless of record overlap.  For well-formed
(sorted, disjoint) lists the output is unchanged; for malformed
overlapping/unsorted lists the chosen record can differ (bsearch instead
of last-record-wins), which makes the subset agree with the clip box
HarfBuzz itself renders from the source font.

Adds an extended-format hb-subset-fuzzer input (5000 records covering
all 65535 glyphs) that the subset-fuzzer tests pick up.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-MRSCGMJ7.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 16:10:42 -06:00
..