drop_hints_in_str()/drop_hints_in_subr() and the closure walk
(collect_subr_refs_in_str/_in_subr) recursively walk the subroutine
calls recorded for each glyph with no depth limit and no work budget.
The records need not match what the interpreter executed: a string is
parsed on its first run only, global subr records are shared across
Font DICTs whose local subrs differ, and endchar does not end a walk.
So the recorded call graph can nest deeper than kMaxCallLimit or be
cyclic, and a binary-tree subr structure makes the hint-dropping walk
expand exponentially. A 360-byte CID font crashed the subsetter with
a stack overflow under --no-hinting (or hb_subset_preprocess), and a
~1 KB font ran unboundedly. PR #6428 rejected stack-supplied call
operands but added no depth, cycle or work limit to these walks, so
these fonts were still affected.
Hold both walks to the interpreter's call-depth limit (kMaxCallLimit),
which stops the cycle and the long chain before the stack runs out, and
charge the hint-dropping walk to the subsetting pass budget introduced
for the shared-subroutine work, so the exponential expansion is capped
too. A walk that follows the interpreter's path stays within both, so
only fonts whose records diverge from their execution are affected;
over either limit the subset fails, as other CFF planning failures do.
Adds test_subset_cff1_subr_loop, which subsets the 360-byte cycle font
with --no-hinting and only requires that hb_subset_or_fail() returns.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-BCC7WHCA.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
cmap-format12-only files created by ttx & remove all other cmap entries
Inconsolata-Regular.abc.widerc.ttf has the hmtx width of "c" set to 600; everything else is 500. Subsetting out c should reduce numberOfHMetrics to 1.
chromacheck-* fonts are from https://github.com/RoelN/ChromaCheck/tree/master/fonts and licensed under MIT by Roel Nieskens and Google.
RanaKufi-Regular.subset.otf is from https://github.com/alif-type/rana-kufi/ but the subset is licensed for us in MIT for the project use.
glyphs.ttf is from https://github.com/RazrFalcon/ttf-parser/blob/337e7d1/tests/fonts/glyphs.ttf
Estedad-VF.ttf, licensed under OFL 1.1, is from https://github.com/aminabedi68/Estedad
graphite2-expansion.ttf is a synthetic three-glyph font generated by
../generate-graphite2-expansion-font.py. Its Graphite substitution rule expands
each "a" to 41 glyphs, for testing buffer growth failure.