• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh -eu
2
3# First step: In the top directory execute
4# export CC=clang-5.0
5# export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp"
6# ./configure --enable-static --disable-gtk-doc --enable-runtime=libidn2 --enable-builtin=libidn2
7# make clean
8# make -j$(nproc) LIB_FUZZING_ENGINE="-lFuzzer"
9# cd fuzz
10# make -j$(nproc) check
11
12#
13# Read the docs at https://github.com/google/oss-fuzz/blob/master/docs/corpora.md
14# then install 'google-cloud-sdk' and execute 'gcloud init'.
15# Now 'gsutil' should be ready to use.
16
17if test -z "$1"; then
18  echo "Usage: $0 <fuzzer target>"
19  echo "Example: $0 libpsl_fuzzer"
20  exit 1
21fi
22
23fuzzer=$1
24project=$(echo $1 | cut -d'_' -f1)
25
26# sync/copy the OSS-Fuzz corpora into the .new directory
27mkdir -p ${fuzzer}.new
28cp -p ${fuzzer}.in/* ${fuzzer}.new
29gsutil -m rsync gs://${project}-corpus.clusterfuzz-external.appspot.com/libFuzzer/${fuzzer} ${fuzzer}.new
30
31# create fuzzer target
32BUILD_ONLY=1 ./run-clang.sh ${fuzzer}
33
34# merge the corpora into the .in directory
35./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new
36
37# now clear .new dir and put all corpora there
38rm -f ${fuzzer}.new/*
39mv ${fuzzer}.in/* ${fuzzer}.new
40
41# now merge again (optimizes number of corpora)
42./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new
43
44echo
45echo "If new files have been added, 'git add' and 'git commit' them."
46