mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
reinterpret_cast<const instructions_t &>(data) reads the bytes of the pointer variable itself (stack address, determined by ASLR), not the fuzzer input buffer. This makes operation and first_set_size effectively uncontrollable by the fuzzer. Fix by dereferencing: reinterpret_cast<const instructions_t &>(*data) This also removes the #pragma suppressing -Wstrict-aliasing, which was warning about exactly this problem. Coverage comparison (10-min libFuzzer run): - Original: 15 lines (0.05%), 2 functions - Fixed: 486 lines (1.47%), 144 functions (29x improvement)
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,draw,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: