Files
Behdad EsfahbodandClaude Opus 4.8 287954c9c5 [gvar] Charge tuple region eval and point-number decoding to work budget
apply_deltas_to_points() only charged the glyph work budget
(HB_BUDGET_GLYPH) for tuple variations that actually applied, and
only by the glyph's point count, after calculate_scalar() had
already walked gvar.axisCount axes for every tuple header.  A
~35 KB font with axisCount 8192 and 4095 non-applying tuples on a
composite-multiplied glyph could hold one hb_font_get_glyph_extents()
call for over a minute while using ~3% of the budget.  Two further
pieces of work were also uncharged: the shared point-number list is
decoded on every glyph load, and an applied tuple decodes/applies
indices.length deltas, which can exceed the point count charged.

Following the project's "charge before doing the work" idiom
(#6256, #6410), charge 1 + axisCount per tuple before its region is
evaluated (bounding calculate_scalar() regardless of the scalar
cache or outcome), shared_indices.length once per load after the
shared point numbers are decoded, and indices.length per applied
tuple before its deltas are decoded.  A font whose tuple work
exceeds the budget now fails the glyph load (outline/extents return
false) instead of finishing slowly; real fonts (a dozen axes, tens
of tuples) pay a few hundred units per load.

Adds test_hb_draw_gvar_budget to test/api/test-draw.c covering both
the unapplied-tuple region charge and the point-number charges.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-09 21:34:03 -06:00
..