Files
harfbuzz/test/fuzzing
Behdad EsfahbodandClaude Sonnet 5.5 e6d5454350 [paint] Clamp hb_color_lerp() channels to [0,255] (#6305)
Sweep-gradient color-stop angles come from the font, so the
interpolation fraction t can fall outside [0,1] (or be NaN).  The
interpolated channel was then cast float -> unsigned directly; a
negative value (e.g. -387.671) is UB (UBSan float-cast-overflow) and
yields meaningless colors on release builds.

Clamp the interpolated channel to [0,255], mapping NaN to 0, before
the cast.  In-range behavior is unchanged.  Add the reported fuzzer
input as a seed.

Reported by iceray-Li.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 18:22:41 -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.