• 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# limit allocation size to reduce spurious OOMs
19WEBP_CFLAGS="$CFLAGS -DWEBP_MAX_IMAGE_SIZE=838860800" # 800MiB
20
21./autogen.sh
22CFLAGS="$WEBP_CFLAGS" ./configure \
23  --enable-asserts \
24  --enable-libwebpdemux \
25  --enable-libwebpmux \
26  --disable-shared \
27  --disable-jpeg \
28  --disable-tiff \
29  --disable-gif \
30  --disable-wic
31make clean
32make -j$(nproc)
33
34find $SRC/libwebp-test-data -type f -size -32k -iname "*.webp" \
35  -exec zip -qju fuzz_seed_corpus.zip "{}" \;
36
37# Simple Decoding API
38$CC $CFLAGS -Isrc -I. -c $SRC/fuzz_simple_api.c
39$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \
40  fuzz_simple_api.o -o $OUT/fuzz_simple_api \
41  src/.libs/libwebp.a
42cp fuzz_seed_corpus.zip $OUT/fuzz_simple_api_seed_corpus.zip
43cp $SRC/fuzz.dict $OUT/fuzz_simple_api.dict
44
45# Advanced Decoding API
46$CC $CFLAGS -Isrc -I. -c $SRC/fuzz_advanced_api.c
47$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \
48  fuzz_advanced_api.o -o $OUT/fuzz_advanced_api \
49  src/.libs/libwebp.a
50cp fuzz_seed_corpus.zip $OUT/fuzz_advanced_api_seed_corpus.zip
51cp $SRC/fuzz.dict $OUT/fuzz_advanced_api.dict
52
53# Animation Decoding API
54$CC $CFLAGS -Isrc -I. -c $SRC/fuzz_animation_api.c
55$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \
56  fuzz_animation_api.o -o $OUT/fuzz_animation_api \
57  src/demux/.libs/libwebpdemux.a \
58  src/.libs/libwebp.a
59cp fuzz_seed_corpus.zip $OUT/fuzz_animation_api_seed_corpus.zip
60cp $SRC/fuzz.dict $OUT/fuzz_animation_api.dict
61
62# Animation Encoding API
63$CC $CFLAGS -Isrc -I. -c $SRC/fuzz_webp_animencoder.cc
64$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \
65  fuzz_webp_animencoder.o -o $OUT/fuzz_webp_animencoder \
66  src/mux/.libs/libwebpmux.a \
67  src/.libs/libwebp.a
68cp fuzz_seed_corpus.zip $OUT/fuzz_webp_animencoder_seed_corpus.zip
69
70# (De)mux API
71$CC $CFLAGS -Isrc -I. -c $SRC/fuzz_demux_api.c
72$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \
73  fuzz_demux_api.o -o $OUT/fuzz_demux_api \
74  src/demux/.libs/libwebpdemux.a src/mux/.libs/libwebpmux.a \
75  src/.libs/libwebp.a
76cp fuzz_seed_corpus.zip $OUT/fuzz_demux_api_seed_corpus.zip
77cp $SRC/fuzz.dict $OUT/fuzz_demux_api.dict
78
79# Encode then Decode
80$CC $CFLAGS -Isrc -I. -c $SRC/fuzz_webp_enc_dec.cc
81$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \
82  fuzz_webp_enc_dec.o -o $OUT/fuzz_webp_enc_dec \
83  src/.libs/libwebp.a
84cp fuzz_seed_corpus.zip $OUT/fuzz_webp_enc_dec_seed_corpus.zip
85