mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
When no extents are set explicitly, the paint and draw contexts
derive the surface size from font data: glyph extents (which the
auto path in hb_raster_paint_glyph_impl () feeds through
set_glyph_extents ()) or the accumulated outline bounds in
hb_raster_draw_render (). A malicious font with a tiny upem and
huge glyph coordinates turns that into arbitrarily large
allocations: a 49 KB fuzz font produced several ~885 MB BGRA
surfaces live at once (root surface plus one per PaintComposite
push_group), nearly 4 GB total.
Add HB_RASTER_MAX_AUTO_DIMENSION (4096) to hb-limits.hh and clamp
width/height at the three font-derived sizing points: both
set_glyph_extents () implementations and draw render's
auto-size-from-edges path. Since push_group and clip surfaces
inherit fixed_extents, the cap bounds those too. Extents set
explicitly via hb_raster_{draw,paint}_set_extents () are not
limited.
Fixes an hb-raster-fuzzer out-of-memory finding (testcase
6344015149858816): peak RSS 3.47 GB before, 350 MB after.
Testcase added as a fuzz seed. Full meson test suite passes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>