• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eux
2# Copyright 2019 Google Inc.
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# util/storage/lookup3.c has some code that triggers the address sanitizer, but
18# according to a comment is OK. -DVALGRIND turns on an alternate version of that
19# code.
20CFLAGS="${CFLAGS} -DVALGRIND=1"
21./configure
22make -j6 all
23
24$CC $CFLAGS -I. -DSRCDIR=. -c -o parse_packet_fuzzer.o parse_packet_fuzzer.c
25$CC $CFLAGS -I. -DSRCDIR=. -c -o fuzz_1.o fuzz_1.c
26$CC $CFLAGS -I. -DSRCDIR=. -c -o fuzz_2.o fuzz_2.c
27$CC $CFLAGS -I. -DSRCDIR=. -c -o fuzz_3.o fuzz_3.c
28$CC $CFLAGS -I. -DSRCDIR=. -c -o fuzz_4.o fuzz_4.c
29
30# get the LIBOBJS with the replaced functions needed for linking.
31LIBOBJS=`make --eval 'echolibobjs: ; @echo "$(LIBOBJS)"' echolibobjs`
32
33OBJECTS_TO_LINK="dns.o infra.o rrset.o dname.o \
34  msgencode.o as112.o msgparse.o msgreply.o packed_rrset.o iterator.o \
35  iter_delegpt.o iter_donotq.o iter_fwd.o iter_hints.o iter_priv.o \
36  iter_resptype.o iter_scrub.o iter_utils.o localzone.o mesh.o modstack.o view.o \
37  outbound_list.o alloc.o config_file.o configlexer.o configparser.o \
38  fptr_wlist.o edns.o locks.o log.o mini_event.o module.o net_help.o random.o \
39  rbtree.o regional.o rtt.o dnstree.o lookup3.o lruhash.o slabhash.o \
40  tcp_conn_limit.o timehist.o tube.o winsock_event.o autotrust.o val_anchor.o \
41  validator.o val_kcache.o val_kentry.o val_neg.o val_nsec3.o val_nsec.o \
42  val_secalgo.o val_sigcrypt.o val_utils.o dns64.o authzone.o \
43  respip.o netevent.o listen_dnsport.o outside_network.o ub_event.o keyraw.o \
44  sbuffer.o wire2str.o parse.o parseutil.o rrdef.o str2wire.o libunbound.o \
45  libworker.o context.o rpz.o"
46
47$CXX $CXXFLAGS -std=c++11 \
48  $LIB_FUZZING_ENGINE \
49  -lssl -lcrypto -pthread \
50  -o $OUT/parse_packet_fuzzer \
51  parse_packet_fuzzer.o \
52  $OBJECTS_TO_LINK \
53  $LIBOBJS
54
55$CXX $CXXFLAGS -std=c++11 \
56  $LIB_FUZZING_ENGINE \
57  -lssl -lcrypto -pthread \
58  -o $OUT/fuzz_1_fuzzer \
59  fuzz_1.o \
60  $OBJECTS_TO_LINK \
61  $LIBOBJS
62
63$CXX $CXXFLAGS -std=c++11 \
64  $LIB_FUZZING_ENGINE \
65  -lssl -lcrypto -pthread \
66  -o $OUT/fuzz_2_fuzzer \
67  fuzz_2.o \
68  $OBJECTS_TO_LINK \
69  $LIBOBJS
70
71$CXX $CXXFLAGS -std=c++11 \
72  $LIB_FUZZING_ENGINE \
73  -lssl -lcrypto -pthread \
74  -o $OUT/fuzz_3_fuzzer \
75  fuzz_3.o \
76  $OBJECTS_TO_LINK \
77  $LIBOBJS
78
79$CXX $CXXFLAGS -std=c++11 \
80  $LIB_FUZZING_ENGINE \
81  -lssl -lcrypto -pthread \
82  -o $OUT/fuzz_4_fuzzer \
83  fuzz_4.o \
84  $OBJECTS_TO_LINK \
85  $LIBOBJS
86
87wget --directory-prefix $OUT https://github.com/jsha/unbound/raw/fuzzing-corpora/testdata/parse_packet_fuzzer_seed_corpus.zip
88wget --directory-prefix $OUT https://github.com/luisx41/fuzzing-corpus/raw/master/projects/unbound/fuzz_1_fuzzer_seed_corpus.zip
89wget --directory-prefix $OUT https://github.com/luisx41/fuzzing-corpus/raw/master/projects/unbound/fuzz_2_fuzzer_seed_corpus.zip
90wget --directory-prefix $OUT https://github.com/luisx41/fuzzing-corpus/raw/master/projects/unbound/fuzz_3_fuzzer_seed_corpus.zip
91wget --directory-prefix $OUT https://github.com/luisx41/fuzzing-corpus/raw/master/projects/unbound/fuzz_4_fuzzer_seed_corpus.zip
92