Files
harfbuzz/test/api
Behdad EsfahbodandClaude Opus 4.8 d35a224377 [subset] Bound avar2 offset-compensation's quadratic breakpoint work
avar::_subset_avar2() builds the offset-compensation knots and runs
_avar2_estimate_offset_error() twice per narrowed axis; every
breakpoint and every estimator sample is looked up in the old
segment map, the instantiated mapping and the knots by linear
search, so the cost is quadratic in the axis's avar breakpoints and
nothing bounded it (42 s of CPU for a 131 KB font, re-run on each
serializer out-of-room retry).

Add HB_BUDGET_SUBSET_TABLE to hb-limits.hh (same hb_budget_spend()
idiom as the rendering budgets) and, right before the knot loop and
the estimator, charge (256 + breakpoints) * 8 * breakpoints from a
budget shared by all axes of the table.  Charging at the point where
the quadratic work starts covers the O(n^2) knot-collection loop and
its map_float() calls too.  On exhaustion the table fails through
c->serializer->check_success(), so the whole subset fails
(hb_subset_or_fail() returns NULL) rather than avar being silently
dropped from an avar2-instanced font.

The budget is 1<<30: a 5,000-breakpoint axis narrowed to -900:900 is
still admitted (0.6 s), while 16,385 and 32,769 breakpoints are
rejected in 0.01 s (the 42 s DoS).  A reviewer may tighten it; real
avar maps have a handful of breakpoints, far below the cap.

Adds test_avar2_restrict_many_breakpoints to test/api/test-subset-avar2.c.

This caps the cost; it does not remove the quadratic algorithm.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-10 16:41:56 -06:00
..
2025-04-06 18:08:50 -06:00
2026-07-30 19:02:25 -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