|
| 1 | +#!/bin/bash -eu |
| 2 | +# Copyright 2020 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 | + |
| 18 | +# Note: This project creates Rust fuzz targets exclusively |
| 19 | + |
| 20 | +export CUSTOM_LIBFUZZER_PATH="$LIB_FUZZING_ENGINE_DEPRECATED" |
| 21 | +export CUSTOM_LIBFUZZER_STD_CXX=c++ |
| 22 | +PROJECT_DIR=$SRC/mp4parse-rust |
| 23 | + |
| 24 | +# Because Rust does not support sanitizers via CFLAGS/CXXFLAGS, the environment |
| 25 | +# variables are overridden with values from base-images/base-clang only |
| 26 | + |
| 27 | +export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" |
| 28 | +export CXXFLAGS_EXTRA="-stdlib=libc++" |
| 29 | +export CXXFLAGS="$CFLAGS $CXXFLAGS_EXTRA" |
| 30 | +export RUSTFLAGS="-Cdebuginfo=1 -Cforce-frame-pointers" |
| 31 | + |
| 32 | +cd $PROJECT_DIR/mp4parse_capi/fuzz && cargo fuzz build -O --debug-assertions |
| 33 | + |
| 34 | +mkdir $PROJECT_DIR/corpus |
| 35 | +cp $PROJECT_DIR/mp4parse/tests/*.mp4 $PROJECT_DIR/corpus |
| 36 | +cp $PROJECT_DIR/mp4parse_capi/tests/*.mp4 $PROJECT_DIR/corpus |
| 37 | + |
| 38 | +FUZZ_TARGET_OUTPUT_DIR=$PROJECT_DIR/mp4parse_capi/fuzz/target/x86_64-unknown-linux-gnu/release |
| 39 | +for f in $SRC/mp4parse-rust/mp4parse_capi/fuzz/fuzz_targets/*.rs |
| 40 | +do |
| 41 | + FUZZ_TARGET_NAME=$(basename ${f%.*}) |
| 42 | + cp $FUZZ_TARGET_OUTPUT_DIR/$FUZZ_TARGET_NAME $OUT/ |
| 43 | + cp $PROJECT_DIR/mp4parse_capi/fuzz/mp4.dict $OUT/$FUZZ_TARGET_NAME.dict |
| 44 | + zip -jr $OUT/${FUZZ_TARGET_NAME}_seed_corpus.zip $PROJECT_DIR/corpus/ |
| 45 | +done |
0 commit comments