From bb2b4bfbc2c6203377a142c3ebb7cd84a4d78e2a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 17 Apr 2026 16:29:06 -0600 Subject: [PATCH] [fuzzing] Cap font scale in raster fuzzer to avoid OOM Malicious fonts with extreme scale values cause huge pixel buffer allocations across multiple push_group surfaces. The library correctly bounds individual surfaces at 1 GB, but stacked group surfaces can exceed the fuzzer RSS limit. Cap the font scale to 1000 in the harness so the exercised surface stays within fuzzer memory constraints. Assisted-by: Claude Opus 4.6 (1M context) --- test/fuzzing/hb-raster-fuzzer.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/fuzzing/hb-raster-fuzzer.cc b/test/fuzzing/hb-raster-fuzzer.cc index bdc785e74..464cb8ce8 100644 --- a/test/fuzzing/hb-raster-fuzzer.cc +++ b/test/fuzzing/hb-raster-fuzzer.cc @@ -20,6 +20,13 @@ extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) } hb_raster_paint_set_foreground (paint, HB_COLOR (0, 0, 0, 255)); + /* Cap font scale so malicious fonts don't produce huge surfaces. */ + int x_scale, y_scale; + hb_font_get_scale (input.font, &x_scale, &y_scale); + if (x_scale > 1000 || x_scale < -1000) x_scale = 1000; + if (y_scale > 1000 || y_scale < -1000) y_scale = 1000; + hb_font_set_scale (input.font, x_scale, y_scale); + unsigned glyph_count = hb_face_get_glyph_count (input.face); unsigned limit = glyph_count > 16 ? 16 : glyph_count;