• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -ex
4
5PROJECT_NAME=libsndfile
6
7# Clone the oss-fuzz repository
8git clone https://github.com/google/oss-fuzz.git /tmp/ossfuzz
9
10if [[ ! -d /tmp/ossfuzz/projects/${PROJECT_NAME} ]]
11then
12    echo "Could not find the ${PROJECT_NAME} project in ossfuzz"
13
14    # Exit with a success code while the libsndfile project is not expected to exist
15    # on oss-fuzz.
16    exit 0
17fi
18
19# Work out which branch to clone from, inside Docker
20BRANCH=${GITHUB_REF}
21
22# Modify the oss-fuzz Dockerfile so that we're checking out the current reference on CI.
23sed -i "s@RUN.*@RUN git config --global remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*' \&\& git clone https://github.com/libsndfile/libsndfile.git /src/libsndfile \&\& cd /src/libsndfile \&\& git checkout -b ${BRANCH}@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile
24
25# Try and build the fuzzers
26pushd /tmp/ossfuzz
27python3 infra/helper.py build_image --pull ${PROJECT_NAME}
28python3 infra/helper.py build_fuzzers ${PROJECT_NAME}
29python3 infra/helper.py check_build ${PROJECT_NAME} --engine libfuzzer --sanitizer address --architecture x86_64
30popd
31