diff options
author | Harish Mahendrakar <harish.mahendrakar@ittiam.com> | 2019-08-26 14:00:15 -0700 |
---|---|---|
committer | Harish Mahendrakar <harish.mahendrakar@ittiam.com> | 2019-10-02 21:43:21 +0000 |
commit | 29a7dc084d6a639429923999aba6412e796c7d24 (patch) | |
tree | 888d4687c66537d77e1ce4798fb6507b62177781 | |
parent | 2caf20ff25c090341965cc88b7f31f129e806a3a (diff) | |
download | libmpeg2-29a7dc084d6a639429923999aba6412e796c7d24.tar.gz |
fuzzer: Create ossfuzz.sh to build with oss-fuzz
fuzzer/ossfuzz.sh added to build libmpeg2 fuzzer target in oss-fuzz.
Bug: 140057362
Test: Build with oss-fuzz
Change-Id: I19cd6b9d9037a99b2533085e0724d79962151d1d
-rwxr-xr-x | fuzzer/ossfuzz.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fuzzer/ossfuzz.sh b/fuzzer/ossfuzz.sh new file mode 100755 index 0000000..3493031 --- /dev/null +++ b/fuzzer/ossfuzz.sh @@ -0,0 +1,44 @@ +#!/bin/bash -eu +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# Ensure SRC and WORK are set +test "${SRC}" != "" || exit 1 +test "${WORK}" != "" || exit 1 +test "${OUT}" != "" || exit 1 + +# Build libmpeg2 +build_dir=$WORK/build +rm -rf ${build_dir} +mkdir -p ${build_dir} +pushd ${build_dir} + +cmake $SRC/libmpeg2 +make -j$(nproc) +popd + +# build fuzzers +$CXX $CXXFLAGS -std=c++11 \ +-I$SRC/libmpeg2 \ +-I$SRC/libmpeg2/common \ +-I$SRC/libmpeg2/decoder \ +-I${build_dir} \ +-Wl,--start-group \ +$LIB_FUZZING_ENGINE \ +$SRC/libmpeg2/fuzzer/mpeg2_dec_fuzzer.cpp -o $OUT/mpeg2_dec_fuzzer \ +${build_dir}/libmpeg2dec.a \ +-Wl,--end-group + +cp $SRC/mpeg2_dec_fuzzer_seed_corpus.zip $OUT/mpeg2_dec_fuzzer_seed_corpus.zip +cp $SRC/libmpeg2/fuzzer/mpeg2_dec_fuzzer.dict $OUT/mpeg2_dec_fuzzer.dict |