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>
* [CFF2] Charge blend region-scalar evaluation to the work budget
cff2_cs_interp_env_t::process_blend() evaluates one VarRegionList scalar
per entry of the VarData's region indices (up to 65535, each walking up
to axisCount axes) the first time a charstring hits `blend`, but the
only budget charge for blend is the operand-proportional one in
cff2_cs_opset_t::process_blend(), which runs afterwards and is skipped
when the operand check fails. So `1 blend` did regionIndexCount x
axisCount scalar evaluations for one budget unit, and a VARC fan-out
re-ran it tens of thousands of times within 2% of HB_BUDGET_GLYPH.
Charge region_count x max(1, axisCount) through the env's existing
spend_budget() right before resizing and filling the scalars vector,
matching how VARC charges values x coords for its own
ItemVariationStore evaluations; a failed charge errors the interpreter
exactly as a failed resize does. spend_budget() is a no-op without a
budget, so the subsetter and instancer paths are unchanged, and
seen_blend gates the work to once per charstring run.
Adds test_hb_draw_cff2_blend_region_budget: a CFF2 charstring blending
one value over 256 region indices of a 16-axis region list must consume
at least 256 x 16 units and fail under a 2048-unit budget.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-WSM91D3G.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [CFF2] Charge the blend default values to the work budget
cff2_cs_opset_t::process_blend() walks all (k+1)*n values of a blend
(n default values plus k deltas each) but charged only the k*n deltas,
total - n. With a VarData of regionIndexCount 0 (or no variation
store) k is 0, so `n blend` charges nothing, pops nothing, and the same
operands can be blended again and again for the price of two tokens.
Charge `total` = (k+1)*n, exactly what the loop touches. spend_budget()
is a no-op without a caller budget, so only budgeted callers (draw,
extents, paint, shape, and the subsetter passes that now pass a budget)
are affected, and a well-formed charstring pays one extra unit per
blended value.
Adds test_hb_draw_cff2_blend_budget: a charstring that pushes 100
numbers and blends them 100 times over a region-less VarData must
consume at least 100 x 100 units and fail under a 5000-unit budget.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-0DAQUESS.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* [glyf] Charge composite offsets to the work budget
Composite glyphs prepare component offsets before descending into
children. This work was not charged to the shared rendering budget,
including offsets for children later skipped by cycle detection.
Repeated preparation through COLR extents could time out the shaper.
Charge each offset before loading it and restore the scratch length
on failure. Add a cyclic-composite budget regression and the minimized
fuzzer testcase.
The full Meson suite passes (292 passed, one skipped). The reproducer
completes under ASan/UBSan in 17 seconds instead of timing out after
60 seconds. A failing-allocation variant passes 100 runs.
Fixes: https://oss-fuzz.com/testcase-detail/6193853460447232
Assisted-by: OpenAI Codex
* [glyf] Charge component preparation as traversal work
Component preparation parses records and updates scratch vectors, but
charging one unit per record still allows excessive work within the
shared budget. Use the existing 16-unit glyph traversal charge for
preparing a component, including children skipped by cycle detection.
Increase the cyclic-composite regression's budget so it also catches
the undercharged preparation path. The reproducer now takes about
1.1 seconds under ASan/UBSan and 0.03 seconds in the normal build.
Tested with the full Meson suite (292 passed, one skipped), 100
sanitizer reproducer runs, and 100 failing-allocation variant runs.
Assisted-by: OpenAI Codex
Exercise CFF work accounting through the public draw-budget callbacks.
Use lower bounds above each parent charstring's flat operator cost so the
CFF1 assertion covers both seac children and the CFF2 assertion covers
proportional blend work.
Keep the interpreter's local cost type consistent with the unsigned spend
interface.
Tests: meson test -C build (275/275 passed)
Assisted-by: OpenAI Codex <codex@openai.com>
Synthetic slant and emboldening first render into an outline recorder.
That adapter previously hid the renderer's live budget, allowing the
underlying outline traversal to use a fresh per-glyph allowance.
Forward the destination draw data's remaining-budget pointer through
the recorder. Add a regression test proving an exhausted synthetic
draw fails against the caller's budget.
Assisted-by: OpenAI Codex <codex@openai.com>
Expose budget policy and remaining-work callbacks on draw and paint function
objects. The public setters clamp invalid negative caps, distinguish finite
defaults from explicit unlimited operation, and report whether a backend
participates in accounting.
Let draw sessions borrow the live counter owned by draw_data. OpenType glyf
and CFF traversal then debit the same counter in place, while unsupported
backends retain a finite per-glyph fallback. Forward budget access through
the parent-font draw adaptor.
Document the new API and cover nil, default, unlimited, clamped, concrete,
and live-depletion behavior.
Tests: meson test -C build (272/272 passed)
Assisted-by: OpenAI Codex <codex@openai.com>
As CI failure, apparently the my local freetype and CI one have different
result so let's switch the case with a simpler one just to test quadratic command
is emitted correctly.
This is unnecessary overhead. Up to rasterizers to handle this. Plus,
this throws off point-numbers in uses that rely on it.
Disabled one test that broke with this.
They aren't contributing to rendering and making issue for stroking, let's skip them
ourselves as Skia does also https://skia-review.googlesource.com/c/skia/+/268166
They are useful for extracting extents and so which that functionality won't be effected by this change.