1#!/bin/bash -eu 2# Copyright 2018 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# build fuzzers 19make -j$(nproc) CC=$CC CXX=$CXX CFLAGS="$CFLAGS" FUZZ_CXXFLAGS="$CXXFLAGS" \ 20 LIB_FUZZING_ENGINE=$LIB_FUZZING_ENGINE fuzz-all 21 22FUZZERS="fuzz-pack-headers fuzz-pack-idx fuzz-commit-graph" 23 24# copy fuzzers 25for fuzzer in $FUZZERS ; do 26 cp $fuzzer $OUT 27done 28 29# build corpora from Git's own packfiles 30zip -j $OUT/fuzz-pack-idx_seed_corpus.zip .git/objects/pack/*.idx 31for packfile in .git/objects/pack/*.pack ; do 32 dd ibs=1 skip=12 if=$packfile of=$packfile.trimmed 33done 34zip -j $OUT/fuzz-pack-headers_seed_corpus.zip .git/objects/pack/*.pack.trimmed 35 36# build commit-graph corpus 37ASAN_OPTIONS=detect_leaks=0 ./git commit-graph write 38zip -j $OUT/fuzz-commit-graph_seed_corpus .git/objects/info/commit-graph 39 40# Mute stderr 41for fuzzer in $FUZZERS ; do 42 cat >$OUT/$fuzzer.options << EOF 43[libfuzzer] 44close_fd_mask = 2 45EOF 46done 47