1#!/bin/bash -eu 2# 3# Copyright 2016 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 19# Build dependencies. 20export XMLSEC_DEPS_PATH=$SRC/xmlsec_deps 21mkdir -p $XMLSEC_DEPS_PATH 22 23cd $SRC/libxml2 24./autogen.sh 25./configure --prefix="$XMLSEC_DEPS_PATH" 26make clean 27make -j$(nproc) all 28make install 29 30cd $SRC/libxslt 31./autogen.sh --prefix="$XMLSEC_DEPS_PATH" 32make -j$(nproc) 33make install 34 35cd $SRC/xmlsec 36autoreconf -vfi 37./configure --with-libxml="$XMLSEC_DEPS_PATH" --with-libxslt="$XMLSEC_DEPS_PATH" 38make -j$(nproc) clean 39make -j$(nproc) all 40 41for file in $SRC/xmlsec/tests/oss-fuzz/*_target.c; do 42 b=$(basename $file _target.c) 43 $CC $CFLAGS -c $file -I /usr/include/libxml2 -I ./include/ \ 44 -o $OUT/${b}_target.o 45 $CXX $CXXFLAGS $OUT/${b}_target.o ./src/.libs/libxmlsec1.a \ 46 ./src/openssl/.libs/libxmlsec1-openssl.a $LIB_FUZZING_ENGINE \ 47 "$XMLSEC_DEPS_PATH"/lib/libxslt.a "$XMLSEC_DEPS_PATH"/lib/libxml2.a \ 48 -lz -o $OUT/${b}_fuzzer 49done 50cp $SRC/xmlsec/tests/oss-fuzz/config/*.options $OUT/ 51wget -O $OUT/xml.dict https://raw.githubusercontent.com/mirrorer/afl/master/dictionaries/xml.dict 52