• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh -eu
2# Copyright 2020 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
18# build the project
19autoreconf -fi
20./configure --disable-shared --enable-static --enable-developer --without-cmocka --without-zlib --disable-linux-caps --prefix="$WORK" --enable-fuzzing=ossfuzz
21(cd lib/isc && make -j"$(nproc)" all V=1)
22(cd lib/dns && make -j"$(nproc)" all V=1)
23
24LIBISC_CFLAGS="-Ilib/isc/unix/include -Ilib/isc/pthreads/include -Ilib/isc/include"
25LIBDNS_CFLAGS="-Ilib/dns/include"
26LIBISC_LIBS="lib/isc/.libs/libisc.a -Wl,-Bstatic -lssl -lcrypto -luv -lnghttp2 -Wl,-Bdynamic"
27LIBDNS_LIBS="lib/dns/.libs/libdns.a -Wl,-Bstatic -lcrypto -Wl,-Bdynamic"
28
29for fuzzer in fuzz/*.c; do
30    output=$(basename "${fuzzer%.c}")
31    [ "$output" = "main" ] && continue
32    # We need to try little bit harder to link everything statically
33    (cd fuzz && make -j"$(nproc)" "${output}.o" V=1)
34    ${CXX} ${CXXFLAGS} \
35	   -o "${OUT}/${output}_fuzzer" \
36	   "fuzz/${output}.o" \
37	   -include config.h \
38	   $LIBISC_CFLAGS $LIBDNS_CFLAGS \
39	   $LIBDNS_LIBS $LIBISC_LIBS $LIB_FUZZING_ENGINE
40    zip -j "${OUT}/${output}_seed_corpus.zip" "fuzz/${output}.in/"*
41done
42