mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
Malformed COLRv1 gradients can report a non-zero stop count and then leave the effective stop array empty once allocations fail. The raster path assumed the second fetch always produced at least one stop and indexed stops[0], which let fuzzing hit a stack-buffer-underflow in evaluate_color_line(). Reject empty effective stop lists after the second fetch, handle zero-stop and one-stop evaluation defensively, and clamp non-finite gradient parameters before lookup. Apply the same stop-fetch hardening to the Cairo and vector paint helpers, including fixing Cairos wrong NULL check after hb_malloc(). Testing: not run (per user request) Fixes: https://oss-fuzz.com/testcase-detail/4635834988167168 Assisted-by: OpenAI Codex
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,set}-fuzzer [-max_len=2048] [CORPUS_DIR]
Where max_len specifies the maximal length of font files to handle. The smaller the faster.
For more details consult the following locations: