Files
harfbuzz/test/api
Behdad EsfahbodandClaude Opus 4.8 6202af118b [buffer] Charge cluster re-merge walks to max_ops
The work budget (max_ops) is meant to bound every buffer pass whose
length the font or text controls, but the same-cluster walks that
re-merge a neighbouring run were never charged:

 - the backward merge in delete_glyph() (reached from an empty
   MultipleSubst Sequence);
 - its copy in delete_glyphs_inplace() (default-ignorable / AAT
   glyph deletion);
 - the "extend" and cross-buffer continuation loops in
   merge_clusters_impl() / merge_out_clusters_impl() (reached from
   the Thai/Lao shaper, the normalizer, morx ligatures, and any
   ligature/multiple substitution).

Once one long same-cluster run exists, every further merge or
deletion next to it walks the whole run again, so a single hb_shape()
call does O(N^2) work the budget never sees: e.g. U+0E01 followed by
130,000 x U+0E33 takes ~21 s.

Charge the glyphs actually walked to max_ops and fail the buffer when
the budget is gone, following shift_forward()/move_to(), and skip the
walk once the buffer has failed (delete_glyphs_inplace() and the
shaper-level merge_clusters() callers keep calling after a failure).
merge_out_clusters_impl() also gains the "cluster != ..." guards that
merge_clusters_impl() already had, so it no longer walks a run that
already holds the merged value; set_cluster() is a no-op on such a
glyph, so output is unchanged.  Verified: default-direction Thai
output is byte-identical to before at sizes that fit the budget, and
pathological inputs now end with hb_buffer_allocation_successful() ==
false, like any other max_ops exhaustion.

Regression test added to test/api/test-shape.c using a stock font.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:24:10 -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-31 16:37:30 -05:00
2020-01-15 13:36:01 -08:00
2025-06-08 13:43:27 +03:00