tuple_variations_t::_cmp_axis_tag() subtracted two axis tags as int. The tags come from the font, so tags far apart in signed range, such as one with the high bit set, overflow the subtraction during partial instancing. UBSan reports signed-integer-overflow from change_tuple_variations_axis_limits(). The wrapped result also makes the comparator inconsistent, for a sort that exists to keep the result deterministic. Use _hb_cmp_operator<hb_tag_t, hb_tag_t>, as other sorts in the tree do, and drop the local comparator. Printable ASCII tags keep their order, so valid fonts are unaffected. Testing: added a 1074-byte fuzzer seed that fails under UBSan without the fix. meson test -C build-asan passes 100/100 with -Db_sanitize=address,undefined -Dexperimental_api=true. The build had no glib, so test/api did not run. Assisted-by: Claude
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.