• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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./bootstrap.sh
19
20# Limit the size of buffer allocations to avoid bogus OOM issues
21# https://github.com/libgd/libgd/issues/422
22sed -i'' -e 's/INT_MAX/100000/' "$SRC/libgd/src/gd_security.c"
23
24./configure --prefix="$WORK" --disable-shared
25make -j$(nproc) install
26
27for target in Bmp Gd Gd2 Gif Jpeg Png Tga Tiff WBMP Webp; do
28    lowercase=$(echo $target | tr "[:upper:]" "[:lower:]")
29    $CXX $CXXFLAGS -std=c++11 -I"$WORK/include" -L"$WORK/lib" \
30      -DFUZZ_GD_FORMAT=$target \
31      $SRC/parser_target.cc -o $OUT/${lowercase}_target \
32      $LIB_FUZZING_ENGINE -lgd -Wl,-Bstatic -lz -Wl,-Bdynamic
33done
34
35mkdir afl_testcases
36(cd afl_testcases; tar xvf "$SRC/afl_testcases.tgz")
37for format in bmp gif png webp; do
38    mkdir $format
39    find afl_testcases -type f -name '*.'$format -exec mv -n {} $format/ \;
40    zip -rj $format.zip $format/
41    cp $format.zip "$OUT/${format}_target_seed_corpus.zip"
42done
43