1#!/bin/bash -eu 2# 3# Copyright 2019 Google Inc. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17################################################################################ 18 19MBEDTLS_BUILD=$WORK/mbedtls 20S2OPC_BUILD=$WORK/s2opc 21SAMPLES=$SRC/S2OPC-fuzzing-data 22 23# Build the dependencies 24tar xzf $SRC/mbedtls.tgz -C $WORK 25mkdir -p $MBEDTLS_BUILD 26cd $MBEDTLS_BUILD 27cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON $WORK/mbedtls-2.* 28make -j$(nproc) 29make -j$(nproc) install 30 31tar xzf $SRC/check.tgz -C $WORK 32cd $WORK/check-0.* 33./configure --prefix=/usr/local --with-tcltk=no 34make -j$(nproc) 35make -j$(nproc) install 36 37# Build S2OPC and the fuzzers 38mkdir -p $S2OPC_BUILD 39cd $S2OPC_BUILD 40cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 41 -DS2OPC_CLIENTSERVER_ONLY=ON \ 42 -DCMAKE_C_COMPILER="$CC" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_EXE_LINKER_FLAGS="$CXXFLAGS" \ 43 -DCMAKE_C_LINK_EXECUTABLE="$CXX <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" \ 44 -DWITH_OSS_FUZZ=ON \ 45 $SRC/S2OPC 46cmake --build . --target fuzzers 47 48# Copy them and build the corpora 49cp bin/* $OUT 50 51cd $SAMPLES 52for dir in $(ls -d */); do 53 zip -j $OUT/${dir%/}_fuzzer_seed_corpus.zip ${dir}* 54done 55