Skip to content

Commit

Permalink
Make fuzzers centipede-compatible (#9599)
Browse files Browse the repository at this point in the history
Link fuzz targets with CXX instead of CC
  • Loading branch information
jonathanmetzman authored Feb 6, 2023
1 parent 9f83585 commit 0dff293
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
7 changes: 5 additions & 2 deletions projects/apache-httpd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
################################################################################

unset CPP
INITIAL_CXX=$CXX
unset CXX
export LDFLAGS="-l:libbsd.a"

Expand All @@ -31,10 +32,12 @@ static_pcre=($(find /src/pcre2 -name "libpcre2-8.a"))

# Build the fuzzers
for fuzzname in utils parse tokenize addr_parse uri request preq; do
$CC $CFLAGS $LIB_FUZZING_ENGINE \
$CC $CFLAGS -c \
-I$SRC/fuzz-headers/lang/c -I./include -I./os/unix \
-I./srclib/apr/include -I./srclib/apr-util/include/ \
$SRC/fuzz_${fuzzname}.c -o $OUT/fuzz_${fuzzname} \
$SRC/fuzz_${fuzzname}.c

$INITIAL_CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz_${fuzzname}.o -o $OUT/fuzz_${fuzzname} \
./modules.o buildmark.o \
-Wl,--start-group ./server/.libs/libmain.a \
./modules/core/.libs/libmod_so.a \
Expand Down
7 changes: 4 additions & 3 deletions projects/gpac/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cd gpac
make

cp $SRC/testsuite/oss-fuzzers/fuzz_parse.c .
$CC $CFLAGS $LIB_FUZZING_ENGINE fuzz_parse.c -o $OUT/fuzz_parse \
-I./include -I./ ./bin/gcc/libgpac_static.a \
-lm -lz -lpthread -lssl -lcrypto -DGPAC_HAVE_CONFIG_H
$CC $CFLAGS -I./include -I./ -DGPAC_HAVE_CONFIG_H -c fuzz_parse.c
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz_parse.o -o $OUT/fuzz_parse \
./bin/gcc/libgpac_static.a \
-lm -lz -lpthread -lssl -lcrypto -DGPAC_HAVE_CONFIG_H
7 changes: 5 additions & 2 deletions projects/libiec61850/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ mkdir build && cd build
cmake ../
make

$CC $CFLAGS $LIB_FUZZING_ENGINE ../fuzz/fuzz_mms_decode.c -o $OUT/fuzz_mms_decode ./src/libiec61850.a \
$CC $CFLAGS $LIB_FUZZING_ENGINE ../fuzz/fuzz_mms_decode.c -c \
-I../src/iec61850/inc -I../src/mms/inc -I../src/common/inc \
-I../hal/inc -I../src/logging ./hal/libhal.a
-I../hal/inc -I../src/logging


$CXX $CXXFLAGS -fuse-ld=lld $LIB_FUZZING_ENGINE fuzz_mms_decode.o -o $OUT/fuzz_mms_decode ./src/libiec61850.a ./hal/libhal.a

# Copy over the options file
cp $SRC/fuzz_decode.options $OUT/fuzz_decode.options
6 changes: 4 additions & 2 deletions projects/libredwg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ sh ./autogen.sh
./configure --disable-shared --disable-bindings --enable-release
make

$CC $CFLAGS $LIB_FUZZING_ENGINE examples/llvmfuzz.c -o $OUT/llvmfuzz \
src/.libs/libredwg.a -I./include -I./src
$CC $CFLAGS src/.libs/libredwg.a -I./include -I./src -c examples/llvmfuzz.c

$CXX $CXXFLAGS $LIB_FUZZING_ENGINE llvmfuzz.o src/.libs/libredwg.a \
-o $OUT/llvmfuzz

cp $SRC/llvmfuzz.options $OUT/llvmfuzz.options
5 changes: 2 additions & 3 deletions projects/libressl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
#
################################################################################

# Held back because of github.com/google/oss-fuzz/pull/8313
# Please fix failure and upgrade.
FROM gcr.io/oss-fuzz-base/base-builder@sha256:111d6b9d3a52bd3392602c71dc8936c628607a7a9bc86d381db7586f9b1e840f
FROM gcr.io/oss-fuzz-base/base-builder

RUN apt-get update && apt-get install -y make cmake wget autoconf automake libtool bison flex texinfo lzip
RUN git clone --depth 1 https://github.com/libressl-portable/portable.git libressl
RUN git clone --depth 1 https://github.com/libressl-portable/fuzz.git libressl.fuzzers
Expand Down
5 changes: 4 additions & 1 deletion projects/libssh/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ for f in $fuzzers; do
fuzzerName=$(basename $f .c)
echo "Building fuzzer $fuzzerName"
$CC $CFLAGS -I$SRC/libssh/include/ -I$SRC/libssh/src/ -I$BUILD/ -I$BUILD/include/ \
"$f" -o "$OUT/$fuzzerName" -O0 -g \
-c "$f" -O0 -g

$CXX $CXXFLAGS $fuzzerName.o \
-o "$OUT/$fuzzerName" -O0 -g \
$LIB_FUZZING_ENGINE ./src/libssh.a -Wl,-Bstatic -lcrypto -lz -Wl,-Bdynamic

if [ -d "$SRC/libssh/tests/fuzz/${fuzzerName}_corpus" ]; then
Expand Down
2 changes: 1 addition & 1 deletion projects/lldpd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
make

$CC $CFLAGS -fPIE -Wall -Werror -pipe -DHAVE_CONFIG_H -I. -I include/ -c FuzzDecode.c
$CC $CFLAGS -fPIE -pie -o FuzzDecode FuzzDecode.o $LIB_FUZZING_ENGINE src/daemon/.libs/liblldpd.a libevent/.libs/libevent.a
$CXX $CXXFLAGS -fPIE -pie -o FuzzDecode FuzzDecode.o $LIB_FUZZING_ENGINE src/daemon/.libs/liblldpd.a libevent/.libs/libevent.a
cp FuzzDecode $OUT/FuzzDecode

pushd $SRC/oss-fuzz-bloat/lldpd/
Expand Down

0 comments on commit 0dff293

Please sign in to comment.