2 # SPDX-License-Identifier: LGPL-2.1+
6 export LC_CTYPE
=C.UTF-8
9 export CXX
=${CXX:-clang++}
10 clang_version
="$($CC --version | sed -nr 's/.*version ([^ ]+?) .*/\1/p' | sed -r 's/-$//')"
12 SANITIZER
=${SANITIZER:-address -fsanitize-address-use-after-scope}
13 flags
="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=$SANITIZER -fsanitize-coverage=trace-pc-guard,trace-cmp"
15 clang_lib
="/usr/lib64/clang/${clang_version}/lib/linux"
16 [ -d "$clang_lib" ] || clang_lib
="/usr/lib/clang/${clang_version}/lib/linux"
18 export CFLAGS
=${CFLAGS:-$flags}
19 export CXXFLAGS
=${CXXFLAGS:-$flags}
20 export LDFLAGS
=${LDFLAGS:--L${clang_lib}}
22 export WORK
=${WORK:-$(pwd)}
23 export OUT
=${OUT:-$(pwd)/out}
30 fuzzflag
="oss-fuzz=true"
31 if [ -z "$FUZZING_ENGINE" ]; then
32 fuzzflag
="llvm-fuzz=true"
35 meson
$build -D$fuzzflag -Db_lundef=false
36 ninja
-C $build fuzzers
38 # The seed corpus is a separate flat archive for each fuzzer,
39 # with a fixed name ${fuzzer}_seed_corpus.zip.
40 for d
in "$(dirname "$0")/../test/fuzz/fuzz-"*; do
41 zip -jqr $OUT/$
(basename "$d")_seed_corpus.
zip "$d"
44 # get fuzz-dns-packet corpus
46 git clone
--depth 1 https
://github.com
/CZ-NIC
/dns-fuzzing
$df
47 zip -jqr $OUT/fuzz-dns-packet_seed_corpus.
zip $df/packet
49 install -Dt $OUT/src
/shared
/ $build/src
/shared
/libsystemd-shared-
*.so
51 wget
-O $OUT/fuzz-json_seed_corpus.
zip https
://storage.googleapis.com
/skia-fuzzer
/oss-fuzz
/skjson_seed_corpus.
zip
52 wget
-O $OUT/fuzz-json.dict https
://raw.githubusercontent.com
/rc0r
/afl-fuzz
/master
/dictionaries
/json.dict
54 find $build -maxdepth 1 -type f
-executable -name "fuzz-*" -exec mv {} $OUT \
;
55 find src
-type f
-name "fuzz-*.dict" -exec cp {} $OUT \
;
56 cp src
/fuzz
/*.options
$OUT