Files
harfbuzz/test/fuzzing
Behdad EsfahbodandClaude Fable 5.1 64e2b53235 [glyf] Charge point loading to the work budget before doing the work (#6256)
The glyf outline budget was only charged after a glyph loaded
successfully: Glyph::get_points() spent 16 units per node up front, and
glyf_accelerator_t::get_points() charged one unit per point only after
the whole tree came back.  A glyph that loaded ~175K points and then
tripped a structural cap (HB_GLYF_MAX_POINTS, edge count) paid for the
nodes but not the points.  Driven from a COLR paint walk through
hb_font_get_glyph_extents(), one such glyph was loaded and thrown away
over 8000 times per session within the budget, ~1.4G point loads.

Charge at the point where the work is attempted instead:

- SimpleGlyph::get_contour_points() takes the budget and charges
  num_points before allocating, clearing, and reading, so truncated or
  later-rejected glyphs pay for the points they allocate.

- Composite levels charge the component subtree size before
  transform_points(), since each nesting level transforms every point
  below it and that multiplication was previously invisible to the
  budget.

The terminal per-point charge for path emission is unchanged.

Local hb-vector-fuzzer run on the testcase: 4.3s -> 0.12s.  Full test
suite passes.  The testcase is added as a fuzz seed.

Fixes: https://oss-fuzz.com/testcase-detail/5714817420427264


Claude-Session: https://claude.ai/code/session_013ksLGe7wUVwbuANqR56YaN

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 22:19:47 -06:00
..
2023-05-27 01:16:46 +02:00
2025-04-06 02:34:48 -06:00

Security Fuzzers

To build the fuzzers with libFuzzer to perform actual fuzzing, build with:

CXX=clang++ CXXFLAGS="-fsanitize=address,fuzzer-no-link" meson fuzzbuild --default-library=static -Dfuzzer_ldflags="-fsanitize=address,fuzzer"

ninja -Cfuzzbuild

Then, run the fuzzer like this:

fuzzbuild/test/fuzzing/hb-{shape,raster,vector,subset,repacker,depend}-fuzzer [-max_len=2048] [CORPUS_DIR]

Where max_len specifies the maximal length of font files to handle. The smaller the faster.

Note: The depend fuzzer requires -Ddepend_api=true meson option.

For more details consult the following locations:

Depend Closure Parity Test

The hb-depend-closure-parity test is distinct from the security fuzzers. While security fuzzers test robustness against malformed input, the closure parity test validates correctness by emulating the glyph closure calculation used for subsetting with one generated from the dependency graph to avoid implementation divergence. It should only be run on valid fonts.