| 1 | #!/bin/bash -eu |
| 2 | |
| 3 | export LDFLAGS="${CFLAGS}" |
| 4 | ./configure --enable-ctrls |
| 5 | make -j$(nproc) |
| 6 | |
| 7 | # We need a few declarations from main.c |
| 8 | # so we rename main() to main2() |
| 9 | sed 's/int main(/int main2(/g' -i $SRC/proftpd/src/main.c |
| 10 | |
| 11 | # Compile main.c again |
| 12 | export NEW_CC_FLAG="${CC} ${CFLAGS} -DHAVE_CONFIG_H -DLINUX -I. -I./include" |
| 13 | $NEW_CC_FLAG -c src/main.c -o src/main.o |
| 14 | rm src/ftpdctl.o |
| 15 | |
| 16 | find . -name "*.o" -exec ar rcs fuzz_lib.a {} \; |
| 17 | |
| 18 | # Build fuzzer(s) |
| 19 | $NEW_CC_FLAG -c $SRC/fuzzer.c -o fuzzer.o |
| 20 | $CC $CXXFLAGS $LIB_FUZZING_ENGINE fuzzer.o -o $OUT/fuzzer \ |
| 21 | src/scoreboard.o \ |
| 22 | lib/prbase.a \ |
| 23 | fuzz_lib.a \ |
| 24 | -L/src/proftpd/lib \ |
| 25 | -lcrypt -pthread |
| 26 | |
| 27 | # Build seed corpus |
| 28 | cd $SRC |
| 29 | git clone https://github.com/dvyukov/go-fuzz-corpus |
| 30 | zip $OUT/fuzzer_seed_corpus.zip go-fuzz-corpus/json/corpus/* |
| 31 |