2016-11-09 03:35:29 +00:00
|
|
|
#!/bin/bash -eux
|
2016-11-08 19:15:23 +00:00
|
|
|
# Copyright 2016 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.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2017-02-18 07:13:50 +00:00
|
|
|
# Disable UBSan vptr since several targets built with -fno-rtti.
|
|
|
|
export CFLAGS="$CFLAGS -fno-sanitize=vptr"
|
|
|
|
export CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr"
|
|
|
|
|
2016-11-08 19:15:23 +00:00
|
|
|
# Build dependencies.
|
2016-11-18 19:16:38 +00:00
|
|
|
export FFMPEG_DEPS_PATH=$SRC/ffmpeg_deps
|
2016-11-08 19:15:23 +00:00
|
|
|
mkdir -p $FFMPEG_DEPS_PATH
|
|
|
|
|
2017-09-01 03:15:27 +00:00
|
|
|
export PATH="$FFMPEG_DEPS_PATH/bin:$PATH"
|
|
|
|
export LD_LIBRARY_PATH="$FFMPEG_DEPS_PATH/lib"
|
2017-05-24 07:56:59 +00:00
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC
|
2016-11-09 03:54:02 +00:00
|
|
|
bzip2 -f -d alsa-lib-*
|
2016-11-08 19:15:23 +00:00
|
|
|
tar xf alsa-lib-*
|
|
|
|
cd alsa-lib-*
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static --disable-shared
|
|
|
|
make clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/fdk-aac
|
2016-11-08 19:15:23 +00:00
|
|
|
autoreconf -fiv
|
2019-10-08 14:40:52 +00:00
|
|
|
CXXFLAGS="$CXXFLAGS -fno-sanitize=shift-base,signed-integer-overflow" \
|
2016-11-08 19:15:23 +00:00
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --disable-shared
|
|
|
|
make clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/libXext
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static
|
|
|
|
make clean
|
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/libXfixes
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static
|
|
|
|
make clean
|
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/libva
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static --disable-shared
|
|
|
|
make clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/libvdpau
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static --disable-shared
|
|
|
|
make clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/libvpx
|
2016-12-28 00:22:12 +00:00
|
|
|
LDFLAGS="$CXXFLAGS" ./configure --prefix="$FFMPEG_DEPS_PATH" \
|
2018-07-26 08:50:05 +00:00
|
|
|
--disable-examples --disable-unit-tests \
|
|
|
|
--size-limit=12288x12288 \
|
|
|
|
--extra-cflags="-DVPX_MAX_ALLOCABLE_MEMORY=1073741824"
|
2016-11-08 19:15:23 +00:00
|
|
|
make clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/ogg
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
2018-10-24 13:36:03 +00:00
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static --disable-crc
|
2016-11-08 19:15:23 +00:00
|
|
|
make clean
|
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/opus
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static
|
|
|
|
make clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/theora
|
2016-11-08 19:15:23 +00:00
|
|
|
# theora requires ogg, need to pass its location to the "configure" script.
|
2016-12-28 00:22:12 +00:00
|
|
|
CFLAGS="$CFLAGS -fPIC" LDFLAGS="-L$FFMPEG_DEPS_PATH/lib/" \
|
2016-11-08 19:15:23 +00:00
|
|
|
CPPFLAGS="$CXXFLAGS -I$FFMPEG_DEPS_PATH/include/" \
|
|
|
|
LD_LIBRARY_PATH="$FFMPEG_DEPS_PATH/lib/" \
|
2017-10-31 22:40:13 +00:00
|
|
|
./autogen.sh
|
2017-10-31 22:41:19 +00:00
|
|
|
./configure --with-ogg="$FFMPEG_DEPS_PATH" --prefix="$FFMPEG_DEPS_PATH" \
|
2017-10-31 22:40:13 +00:00
|
|
|
--enable-static --disable-examples
|
2016-11-08 19:15:23 +00:00
|
|
|
make clean
|
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/vorbis
|
2016-11-08 19:15:23 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$FFMPEG_DEPS_PATH" --enable-static
|
|
|
|
make clean
|
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
|
|
|
|
# Remove shared libraries to avoid accidental linking against them.
|
|
|
|
rm $FFMPEG_DEPS_PATH/lib/*.so
|
|
|
|
rm $FFMPEG_DEPS_PATH/lib/*.so.*
|
|
|
|
|
2016-11-29 19:33:34 +00:00
|
|
|
# Build ffmpeg.
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/ffmpeg
|
2016-11-08 19:15:23 +00:00
|
|
|
PKG_CONFIG_PATH="$FFMPEG_DEPS_PATH/lib/pkgconfig" ./configure \
|
|
|
|
--cc=$CC --cxx=$CXX --ld="$CXX $CXXFLAGS -std=c++11" \
|
|
|
|
--extra-cflags="-I$FFMPEG_DEPS_PATH/include" \
|
|
|
|
--extra-ldflags="-L$FFMPEG_DEPS_PATH/lib" \
|
|
|
|
--prefix="$FFMPEG_DEPS_PATH" \
|
|
|
|
--pkg-config-flags="--static" \
|
2018-05-30 01:05:13 +00:00
|
|
|
--enable-ossfuzz \
|
2019-05-01 15:09:55 +00:00
|
|
|
--libfuzzer=$LIB_FUZZING_ENGINE \
|
2017-05-01 00:21:28 +00:00
|
|
|
--optflags=-O1 \
|
2016-11-08 19:15:23 +00:00
|
|
|
--enable-gpl \
|
|
|
|
--enable-libass \
|
|
|
|
--enable-libfdk-aac \
|
|
|
|
--enable-libfreetype \
|
|
|
|
--enable-libopus \
|
|
|
|
--enable-libtheora \
|
|
|
|
--enable-libvorbis \
|
|
|
|
--enable-libvpx \
|
|
|
|
--enable-nonfree \
|
2019-07-14 18:50:18 +00:00
|
|
|
--disable-muxers \
|
|
|
|
--disable-protocols \
|
2020-06-07 01:25:28 +00:00
|
|
|
--disable-demuxer=rtp,rtsp,sdp \
|
2019-07-14 18:50:18 +00:00
|
|
|
--disable-devices \
|
2016-11-08 19:15:23 +00:00
|
|
|
--disable-shared
|
|
|
|
make clean
|
|
|
|
make -j$(nproc) install
|
|
|
|
|
2016-11-10 12:22:50 +00:00
|
|
|
# Download test sampes, will be used as seed corpus.
|
2017-05-04 21:43:16 +00:00
|
|
|
# DISABLED.
|
|
|
|
# TODO: implement a better way to maintain a minimized seed corpora
|
|
|
|
# for all targets. As of 2017-05-04 now the combined size of corpora
|
|
|
|
# is too big for ClusterFuzz (over 10Gb compressed data).
|
2020-04-01 23:51:53 +00:00
|
|
|
export TEST_SAMPLES_PATH=$SRC/ffmpeg/fate-suite/
|
|
|
|
make fate-rsync SAMPLES=$TEST_SAMPLES_PATH
|
2016-11-08 19:15:23 +00:00
|
|
|
|
|
|
|
# Build the fuzzers.
|
2016-11-18 19:16:38 +00:00
|
|
|
cd $SRC/ffmpeg
|
2016-11-08 19:15:23 +00:00
|
|
|
|
2017-01-31 14:13:31 +00:00
|
|
|
FUZZ_TARGET_SOURCE=$SRC/ffmpeg/tools/target_dec_fuzzer.c
|
|
|
|
|
2016-11-08 19:15:23 +00:00
|
|
|
export TEMP_VAR_CODEC="AV_CODEC_ID_H264"
|
|
|
|
export TEMP_VAR_CODEC_TYPE="VIDEO"
|
|
|
|
|
2019-12-08 01:56:58 +00:00
|
|
|
CONDITIONALS=`grep 'BSF 1$' config.h | sed 's/#define CONFIG_\(.*\)_BSF 1/\1/'`
|
|
|
|
for c in $CONDITIONALS ; do
|
|
|
|
fuzzer_name=ffmpeg_BSF_${c}_fuzzer
|
|
|
|
symbol=`echo $c | sed "s/.*/\L\0/"`
|
|
|
|
echo -en "[libfuzzer]\nmax_len = 1000000\n" > $OUT/${fuzzer_name}.options
|
|
|
|
make tools/target_bsf_${symbol}_fuzzer
|
|
|
|
mv tools/target_bsf_${symbol}_fuzzer $OUT/${fuzzer_name}
|
|
|
|
done
|
|
|
|
|
2017-05-01 00:21:28 +00:00
|
|
|
# Build fuzzers for decoders.
|
2017-05-04 17:47:39 +00:00
|
|
|
CONDITIONALS=`grep 'DECODER 1$' config.h | sed 's/#define CONFIG_\(.*\)_DECODER 1/\1/'`
|
|
|
|
for c in $CONDITIONALS ; do
|
|
|
|
fuzzer_name=ffmpeg_AV_CODEC_ID_${c}_fuzzer
|
2018-02-15 15:04:51 +00:00
|
|
|
symbol=`echo $c | sed "s/.*/\L\0/"`
|
2016-11-18 19:16:38 +00:00
|
|
|
echo -en "[libfuzzer]\nmax_len = 1000000\n" > $OUT/${fuzzer_name}.options
|
2017-05-04 17:47:39 +00:00
|
|
|
make tools/target_dec_${symbol}_fuzzer
|
|
|
|
mv tools/target_dec_${symbol}_fuzzer $OUT/${fuzzer_name}
|
2016-11-08 19:15:23 +00:00
|
|
|
done
|
2016-11-10 12:22:50 +00:00
|
|
|
|
2019-06-03 15:49:12 +00:00
|
|
|
# Build fuzzer for demuxer
|
|
|
|
fuzzer_name=ffmpeg_DEMUXER_fuzzer
|
|
|
|
echo -en "[libfuzzer]\nmax_len = 1000000\n" > $OUT/${fuzzer_name}.options
|
|
|
|
make tools/target_dem_fuzzer
|
|
|
|
mv tools/target_dem_fuzzer $OUT/${fuzzer_name}
|
|
|
|
|
2020-04-01 23:51:53 +00:00
|
|
|
# We do not need raw reference files for the muxer
|
|
|
|
rm `find fate-suite -name '*.s16'`
|
|
|
|
rm `find fate-suite -name '*.dec'`
|
|
|
|
rm `find fate-suite -name '*.pcm'`
|
|
|
|
|
|
|
|
zip -r $OUT/${fuzzer_name}_seed_corpus.zip fate-suite
|
|
|
|
|
2016-11-10 12:22:50 +00:00
|
|
|
# Find relevant corpus in test samples and archive them for every fuzzer.
|
2017-05-04 21:43:16 +00:00
|
|
|
#cd $SRC
|
|
|
|
#python group_seed_corpus.py $TEST_SAMPLES_PATH $OUT/
|