mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 06:51:01 +01:00
A kerx format-4 control-point action asks the font for two glyph contour points, which the font functions may satisfy by loading the whole glyph outline (two full FT_Load_Glyph calls with hb-ft). The state-machine driver charges a non-advancing transition only one op, so a looping entry turned the whole work budget into glyph loads: two letters and a 680-byte font stalled hb_shape() for seconds. Charge 2 * HB_BUDGET_256 to buffer->max_ops at the action, before the callbacks, using the same decrement-and-return idiom morx insertion uses; once the budget is spent the action is skipped and the driver's existing max_ops check forces the machine forward. The sibling GPOS AnchorFormat2 contour-point path has the same uncharged callback but lives in the layout subsystem and is left for a separate change. GDEF CaretValueFormat2 also calls it but only from hb_ot_layout_get_ligature_carets, bounded per API call. Regression test in test/api/test-shape.c uses a counting glyph_contour_point callback on a builder-made looping kerx font (131074 calls before, <= 256 after). Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-EE451WE1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>