mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-23 07:51:10 +01:00
hb_cairo_glyphs_from_buffer() asserted that buffer clusters are monotone in the buffer direction, but hb_shape() does not guarantee that: HB_BUFFER_CLUSTER_LEVEL_CHARACTERS, shaping that hits the ops limit mid-lookup, and Indic reordering corner cases can all produce non-monotone clusters. The function runs from HarfBuzz's own cairo text_to_glyphs callback on attacker-controlled text and fonts, so the assertion was an input-dependent abort (and, with NDEBUG, an unchecked backward walk off the ends of the utf8 buffer). The cluster-counting loop that already walks the buffer now detects a step against the buffer's direction and falls back to a single cairo cluster mapping all of the utf8 to all of the glyphs, which cairo accepts. The monotonicity assertions in the fill step then hold by construction and glyph output is unchanged for monotone buffers. A regression test in test/api/test-cairo.c feeds monotone and non-monotone LTR/RTL buffers through both cluster modes and checks the cluster counts and byte/glyph totals; it aborts on the pristine tree. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-T4PZ1H72. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>