• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2018 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
18#compile and link statically dependencies
19cd ..
20cd libgpg-error
21./autogen.sh
22./configure --disable-doc --enable-static --disable-shared
23make
24make install
25cd ..
26cd libgcrypt
27./autogen.sh
28./configure --disable-doc --enable-static --disable-shared
29make
30make install
31cd ..
32cd libassuan
33./autogen.sh
34./configure --disable-doc --enable-static --disable-shared
35make
36make install
37cd ..
38cd libksba
39./autogen.sh
40./configure --disable-doc --enable-static --disable-shared
41make
42make install
43cd ..
44cd npth
45./autogen.sh
46./configure --disable-doc --enable-static --disable-shared
47make
48make install
49cd ..
50
51
52# build project
53cd gnupg
54mkdir tests/fuzz
55cp ../fuzz_* tests/fuzz
56git apply ../fuzz.diff
57./autogen.sh
58./configure --disable-doc --enable-maintainer-mode
59make -j$(nproc) all
60
61# build fuzzers
62cd tests/fuzz
63#export other associated stuff
64cp *.options $OUT/
65cp fuzz_*_seed_corpus.zip $OUT/
66
67ls fuzz_*.c | cut -d_ -f2 | cut -d. -f1 | while read target
68do
69    $CC $CFLAGS -DHAVE_CONFIG_H -I. -I../..  -I../../common -I../../g10 -c fuzz_$target.c -o fuzz_$target.o
70
71    $CXX $CXXFLAGS -std=c++11 -DHAVE_CONFIG_H fuzz_$target.o -o $OUT/fuzz_$target ../../g10/libgpg.a ../../kbx/libkeybox.a ../../common/libcommon.a ../../common/libgpgrl.a $LIB_FUZZING_ENGINE -lgcrypt -lgpg-error -lassuan -lnpth
72done
73