]>
Commit | Line | Data |
---|---|---|
dec64820 EV |
1 | #!/bin/bash |
2 | ||
3 | set -ex | |
4 | ||
5 | export SANITIZER=${SANITIZER:-address} | |
6 | flags="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" | |
dec64820 EV |
7 | coverage_flags="-fsanitize=fuzzer-no-link" |
8 | ||
745d6048 EV |
9 | sanitizer_flags="-fsanitize=address -fsanitize-address-use-after-scope" |
10 | if [[ "$SANITIZER" == "undefined" ]]; then | |
11 | sanitizer_flags="-fsanitize=undefined" | |
12 | elif [[ "$SANITIZER" == "memory" ]]; then | |
13 | sanitizer_flags="-fsanitize=memory -fsanitize-memory-track-origins" | |
14 | fi | |
15 | ||
dec64820 EV |
16 | export CC=${CC:-clang} |
17 | export CFLAGS=${CFLAGS:-$flags $sanitizer_flags $coverage_flags} | |
18 | ||
19 | export CXX=${CXX:-clang++} | |
20 | export CXXFLAGS=${CXXFLAGS:-$flags $sanitizer_flags $coverage_flags} | |
21 | ||
22 | export OUT=${OUT:-$(pwd)/out} | |
23 | mkdir -p $OUT | |
24 | ||
25 | export LIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE:--fsanitize=fuzzer} | |
26 | ||
dec64820 EV |
27 | # AFL++ and hoggfuzz are both incompatible with lto=thin apparently |
28 | sed -i '/-flto=thin/d' configure.ac | |
29 | ||
30 | # turn off the libutil dependency | |
31 | sed -i 's/^AC_CHECK_LIB(util/#/' configure.ac | |
32 | ||
33 | ./autogen.sh | |
34 | ./configure \ | |
35 | --disable-tools \ | |
36 | --disable-commands \ | |
37 | --disable-apparmor \ | |
38 | --disable-openssl \ | |
39 | --disable-selinux \ | |
40 | --disable-seccomp \ | |
49ffe5da EV |
41 | --disable-capabilities \ |
42 | --disable-no-undefined | |
dec64820 EV |
43 | |
44 | make -j$(nproc) | |
45 | ||
46 | $CC -c -o fuzz-lxc-config-read.o $CFLAGS -Isrc -Isrc/lxc src/tests/fuzz-lxc-config-read.c | |
47 | $CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz-lxc-config-read.o src/lxc/.libs/liblxc.a -o $OUT/fuzz-lxc-config-read | |
48 | ||
593f13bf EV |
49 | perl -lne 'if (/config_jump_table\[\]\s*=/../^}/) { /"([^"]+)"/ && print "$1=" }' src/lxc/confile.c >doc/examples/keys.conf |
50 | [[ -s doc/examples/keys.conf ]] | |
51 | ||
52 | perl -lne 'if (/config_jump_table_net\[\]\s*=/../^}/) { /"([^"]+)"/ && print "lxc.net.$1=" }' src/lxc/confile.c >doc/examples/lxc-net-keys.conf | |
53 | [[ -s doc/examples/lxc-net-keys.conf ]] | |
54 | ||
dec64820 | 55 | zip -r $OUT/fuzz-lxc-config-read_seed_corpus.zip doc/examples |