• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
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
18export ASAN_OPTIONS=alloc_dealloc_mismatch=0
19
20if [[ $CFLAGS = *sanitize=address* ]]
21then
22    export CXXFLAGS="$CXXFLAGS -DASAN"
23fi
24
25if [[ $CFLAGS = *sanitize=memory* ]]
26then
27    export CXXFLAGS="$CXXFLAGS -DMSAN"
28fi
29
30if [[ $SANITIZER = coverage ]]
31then
32    export CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit"
33fi
34
35mkdir $SRC/protobuf-install/
36cd $SRC/protobuf/
37./autogen.sh
38./configure --prefix=$SRC/protobuf-install
39make -j$(nproc)
40make install
41
42export PROTOC="$SRC/protobuf-install/bin/protoc"
43
44cd $SRC/protobuf-c/
45./autogen.sh
46./configure --enable-static=yes --enable-shared=false PKG_CONFIG_PATH=$SRC/protobuf-install/lib/pkgconfig
47
48make -j$(nproc)
49
50cd $SRC/fuzzing-headers/
51./install.sh
52
53cd $SRC/protobuf-c-fuzzers/
54cp $SRC/protobuf-c/t/test-full.proto $SRC/protobuf-c-fuzzers/
55export PATH=$PATH:$SRC/protobuf-c/protoc-c
56$PROTOC --c_out=. test-full.proto
57$CC $CFLAGS test-full.pb-c.c -I $SRC/protobuf-install -I $SRC/protobuf-c -c -o test-full.pb-c.o
58$CXX $CXXFLAGS fuzzer.cpp -I $SRC/protobuf-install -I $SRC/protobuf-c test-full.pb-c.o $SRC/protobuf-c/protobuf-c/.libs/libprotobuf-c.a $LIB_FUZZING_ENGINE -o $OUT/fuzzer
59