[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) <noreply@anthropic.com>
This commit is contained in:
Behdad Esfahbod committed 2026-04-17 16:29:06 -06:00
1 parent e4d1127676
commit bb2b4bfbc2
1 file changed
+7
+7
View File
@@ -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;