Files
harfbuzz/test/api/fonts/context-format6.ttf
nussaiba shaikh d2202126e2 Read 24-bit coverage offsets in ContextFormat3_6::depend
ContextFormat3_6<MediumTypes> (context format 6) stores its input
Coverage offsets as Offset24, but depend() passed them to
context_depend_lookup() cast to HBUINT16, so every input position
after the first decoded the wrong bytes as its offset.
intersects_coverage() then followed that value to a Coverage table
sanitize never checked.

With small offsets the misread value is 0, which points at the
subtable header, and the nested lookup's dependencies are silently
dropped.  A crafted rule can instead point the misread offset at bytes
shaped like a large Coverage, and CoverageFormat1_3::intersects() reads
past the end of the GSUB blob (ASan heap-buffer-overflow via
hb_subset_depend_from_face_or_fail).

The other ContextFormat3_6 methods pass coverageZ.arrayZ + 1 as is and
let glyph_data_t pick the width.  Do the same here.
ChainContextFormat3 has the same cast but only has a 16-bit
instantiation.

Add a format 6 font and test to test-ot-depend.c; it fails without
the fix.  Tested with meson test under ASan+UBSan with
-Dexperimental_api=true.

Assisted-by: Claude
2026-10-28 00:03:22 +05:30

160 B