1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00
libxml2/fuzz/oss-fuzz-build.sh
2024-05-28 22:52:30 +02:00

59 lines
1.3 KiB
Bash
Executable File

#!/bin/bash -eu
# OSS-Fuzz integration, see
# https://github.com/google/oss-fuzz/tree/master/projects/libxml2
# Add extra UBSan checks
if [ "$SANITIZER" = undefined ]; then
extra_checks="integer,float-divide-by-zero"
extra_cflags="-fsanitize=$extra_checks -fno-sanitize-recover=$extra_checks"
export CFLAGS="$CFLAGS $extra_cflags"
export CXXFLAGS="$CXXFLAGS $extra_cflags"
fi
# Don't enable zlib and liblzma with MSan
if [ "$SANITIZER" = memory ]; then
CONFIG=''
else
CONFIG='--with-zlib --with-lzma'
fi
# Workaround for a LeakSanitizer crashes,
# see https://github.com/google/oss-fuzz/issues/11798.
if [ "$ARCHITECTURE" = "aarch64" ]; then
export ASAN_OPTIONS=detect_leaks=0
fi
export V=1
./autogen.sh \
--disable-shared \
--without-debug \
--without-http \
--without-python \
$CONFIG
make -j$(nproc)
cd fuzz
make clean-corpus
make fuzz.o
for fuzzer in \
api html lint reader regexp schema uri valid xinclude xml xpath
do
make $fuzzer.o
# Link with $CXX
$CXX $CXXFLAGS \
$fuzzer.o fuzz.o \
-o $OUT/$fuzzer \
$LIB_FUZZING_ENGINE \
../.libs/libxml2.a -Wl,-Bstatic -lz -llzma -Wl,-Bdynamic
if [ $fuzzer != api ]; then
[ -e seed/$fuzzer ] || make seed/$fuzzer.stamp
zip -j $OUT/${fuzzer}_seed_corpus.zip seed/$fuzzer/*
fi
done
cp *.dict *.options $OUT/