2020-08-12 19:21:42 +00:00
|
|
|
#!/bin/sh -eu
|
|
|
|
# Copyright 2020 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# build the project
|
|
|
|
autoreconf -fi
|
2022-12-07 20:30:38 +00:00
|
|
|
./configure --disable-shared --enable-static --enable-developer --without-cmocka --without-zlib --prefix="$WORK" --enable-fuzzing=ossfuzz
|
2023-04-03 12:16:12 +00:00
|
|
|
make -C lib/isc -j"$(nproc)" all V=1
|
|
|
|
make -C lib/dns -j"$(nproc)" all V=1
|
|
|
|
make -C tests/libtest -j"$(nproc)" all V=1
|
2020-08-12 19:21:42 +00:00
|
|
|
|
2023-04-03 12:16:12 +00:00
|
|
|
LIBISC_CFLAGS="-Ilib/isc/include"
|
2020-08-12 19:21:42 +00:00
|
|
|
LIBDNS_CFLAGS="-Ilib/dns/include"
|
2023-04-03 12:16:12 +00:00
|
|
|
LIBISC_LIBS="lib/isc/.libs/libisc.a -Wl,-Bstatic -Wl,-u,isc__initialize,-u,isc__shutdown -lssl -lcrypto -lurcu-qsbr -lurcu-cds -luv -lnghttp2 -Wl,-Bdynamic"
|
|
|
|
LIBDNS_LIBS="lib/dns/.libs/libdns.a -Wl,-Bstatic -lcrypto -lurcu-qsbr -lurcu-cds -Wl,-Bdynamic"
|
|
|
|
LIBTEST_LIBS="tests/libtest/.libs/libtest.a"
|
2020-08-12 19:21:42 +00:00
|
|
|
|
2022-12-07 20:30:38 +00:00
|
|
|
# dns_name_fromwire needs old.c/old.h code to be linked in
|
|
|
|
sed -i 's/#include "old.h"/#include "old.c"/' fuzz/dns_name_fromwire.c
|
|
|
|
|
2020-08-12 19:21:42 +00:00
|
|
|
for fuzzer in fuzz/*.c; do
|
|
|
|
output=$(basename "${fuzzer%.c}")
|
|
|
|
[ "$output" = "main" ] && continue
|
2022-12-07 20:30:38 +00:00
|
|
|
[ "$output" = "old" ] && continue
|
2020-08-12 21:16:48 +00:00
|
|
|
# We need to try little bit harder to link everything statically
|
2023-04-03 12:16:12 +00:00
|
|
|
make -C fuzz -j"$(nproc)" "${output}.o" V=1
|
2020-08-12 19:21:42 +00:00
|
|
|
${CXX} ${CXXFLAGS} \
|
|
|
|
-o "${OUT}/${output}_fuzzer" \
|
|
|
|
"fuzz/${output}.o" \
|
|
|
|
-include config.h \
|
|
|
|
$LIBISC_CFLAGS $LIBDNS_CFLAGS \
|
2023-04-03 12:16:12 +00:00
|
|
|
$LIBDNS_LIBS $LIBISC_LIBS $LIBTEST_LIBS $LIB_FUZZING_ENGINE
|
2020-08-12 19:21:42 +00:00
|
|
|
zip -j "${OUT}/${output}_seed_corpus.zip" "fuzz/${output}.in/"*
|
|
|
|
done
|