[vector][colr] Sanitize ColorLine extend values

COLR ColorLine::get_extend() cast the raw Extend byte directly to
hb_paint_extend_t. Malformed tables can carry out-of-range values,
which then trip UBSan enum checks in vector paint paths.

Map raw extend values explicitly and fall back to PAD for unknown
values.

Tested:
- CCACHE_DISABLE=1 ninja -C /home/behdad/harfbuzz/build-codex test/fuzzing/hb-vector-fuzzer test/fuzzing/hb-raster-fuzzer
- ./build-codex/test/fuzzing/hb-vector-fuzzer test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5448347908636672
- ./build-codex/test/fuzzing/hb-vector-fuzzer test/fuzzing/fonts/NotoColorEmoji.subset.ttf

Fixes: https://oss-fuzz.com/testcase-detail/6120408016551936
Assisted-by: OpenAI Codex
This commit is contained in:
Behdad Esfahbod committed 2026-03-17 09:33:31 -06:00
1 parent acc0a54ddc
commit df9b6ff641
2 files changed
+7 -1

No files matched your search

+7 -1
View File
@@ -525,7 +525,13 @@ struct ColorLine
hb_paint_extend_t get_extend () const
{
return (hb_paint_extend_t) (unsigned int) extend;
switch ((unsigned int) extend)
{
case Extend::EXTEND_REPEAT: return HB_PAINT_EXTEND_REPEAT;
case Extend::EXTEND_REFLECT: return HB_PAINT_EXTEND_REFLECT;
case Extend::EXTEND_PAD:
default: return HB_PAINT_EXTEND_PAD;
}
}
HB_INTERNAL static hb_paint_extend_t static_get_extend (hb_color_line_t *color_line,