Files
harfbuzz/test/api
Behdad EsfahbodandClaude Opus 4.8 fc302bdfe5 [subset] Share one work budget across all glyphs when instancing glyf
hb-limits.hh states that a session which drives another subsystem
carries one cumulative budget, initialized once per top-level entry and
only ever decremented.  When instancing, glyf::subset() drives
Glyph::get_points() once per retained glyph to recompute bounds and
metrics, but passed no budget, so each glyph restarted from a fresh
HB_BUDGET_GLYPH and the table as a whole was bounded only by 2^24 times
the glyph count.  A 59 KB font of 2,000 nested composites over a shared
64-level chain made one hb_subset_or_fail() instancing call spend 34 s
of CPU, since the shared chain was re-walked (and re-charged only
against a fresh budget) for every top-level glyph.

Add HB_BUDGET_SUBSET_GLYF and keep the live counter in
hb_subset_context_t, which is constructed once and reused across the
ran-out-of-room retries in _hb_subset_table_try(), so a retry does not
reset it.  Thread it through _populate_subset_glyphs() and both
compile_bytes_with_deltas() into get_points().  Exhausting it fails
get_points(), which the existing loop already turns into dropping glyf
from the instance -- the same outcome as any other glyph-load failure
there.

This is one cumulative counter, not a per-glyph budget multiplied by
the glyph count.  It is sized at 2^28; measured consumption of the
largest glyf variable font under test/ (MPLUS1-Variable) is ~1.2M
units, about 220x below the cap, and even a font at the 65,535-glyph
maximum stays well under, so real fonts instance unchanged (outputs
byte-identical).  One behaviour change: a single glyph is now bounded
by what is left of the table budget rather than by HB_BUDGET_GLYPH, so
one glyph may spend between 2^24 and 2^28 units; the session total is
still bounded.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-31 22:00:12 -06:00
..
2025-04-06 18:08:50 -06:00
2026-07-30 19:02:25 -06:00
2026-09-04 14:14:49 -06:00
2026-07-31 04:31:26 +03:00
2025-04-05 22:37:10 -06:00
2020-01-15 13:36:01 -08:00
2025-06-08 13:43:27 +03:00