mirror of https://github.com/google/oss-fuzz.git
51 lines
1.6 KiB
Plaintext
51 lines
1.6 KiB
Plaintext
|
#!/bin/bash -u
|
||
|
# Copyright 2020 Google Inc.
|
||
|
#
|
||
|
# 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.
|
||
|
#
|
||
|
################################################################################
|
||
|
|
||
|
# Wrapper around bad_build_check that moves the /out directory to /tmp/not-out.
|
||
|
# This is useful when bad_build_check isn't called from test_all which does the
|
||
|
# same thing.
|
||
|
|
||
|
function main {
|
||
|
# Move the directory the fuzzer is located in to somewhere that doesn't exist
|
||
|
# on the builder to make it more likely that hardcoding /out fails here (since
|
||
|
# it will fail on ClusterFuzz).
|
||
|
local fuzzer=$1
|
||
|
fuzzer=$(realpath $fuzzer)
|
||
|
local initial_fuzzer_dir=$(dirname $fuzzer)
|
||
|
|
||
|
local tmp_fuzzer_dir=/tmp/not-out
|
||
|
rm -rf $tmp_fuzzer_dir
|
||
|
mkdir $tmp_fuzzer_dir
|
||
|
# Move the contents of $initial_fuzzer_dir rather than the directory itself in
|
||
|
# case it is a mount.
|
||
|
mv $initial_fuzzer_dir/* $tmp_fuzzer_dir
|
||
|
fuzzer="$tmp_fuzzer_dir/$(basename $fuzzer)"
|
||
|
|
||
|
bad_build_check $fuzzer
|
||
|
returncode=$?
|
||
|
|
||
|
mv $tmp_fuzzer_dir/* $initial_fuzzer_dir
|
||
|
exit returncode
|
||
|
}
|
||
|
|
||
|
if [ $# -ne 1 ]; then
|
||
|
echo "Usage: $0 <fuzz_target_binary>"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
main $1
|