1#!/bin/bash -eu 2# Copyright 2021 Google LLC. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18export LDFLAGS="${CFLAGS}" 19./configure --enable-ctrls 20make -j$(nproc) 21 22# We need a few declarations from main.c 23# so we rename main() to main2() 24sed 's/int main(/int main2(/g' -i $SRC/proftpd/src/main.c 25 26# Compile main.c again 27export NEW_CC_FLAG="${CC} ${CFLAGS} -DHAVE_CONFIG_H -DLINUX -I. -I./include" 28$NEW_CC_FLAG -c src/main.c -o src/main.o 29rm src/ftpdctl.o 30 31find . -name "*.o" -exec ar rcs fuzz_lib.a {} \; 32 33# Build fuzzer(s) 34$NEW_CC_FLAG -c $SRC/fuzzer.c -o fuzzer.o 35$CC $CXXFLAGS $LIB_FUZZING_ENGINE fuzzer.o -o $OUT/fuzzer \ 36 src/scoreboard.o \ 37 lib/prbase.a \ 38 fuzz_lib.a \ 39 -L/src/proftpd/lib \ 40 -lcrypt -pthread 41 42# Build seed corpus 43cd $SRC 44git clone https://github.com/dvyukov/go-fuzz-corpus 45zip $OUT/fuzzer_seed_corpus.zip go-fuzz-corpus/json/corpus/* 46 47