• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2021 Google LLC
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# Use OSS-Fuzz environment rather than hardcoded setup.
19sed -i 's/-fsanitize-coverage=trace-pc-guard//g' ./configure.ac
20sed -i 's/-fsanitize-coverage=trace-cmp//g' ./configure.ac
21sed -i 's/-fsanitize-coverage=trace-pc//g' ./configure.ac
22sed -i 's/-lFuzzer//g'  ./configure.ac
23
24# In order to build statically we avoid libxml and ogg plugins.
25sed -i 's/..\/..\/lib\/libvlc_internal.h/lib\/libvlc_internal.h/g' ./test/src/input/decoder.c
26sed -i 's/..\/modules\/libxml_plugin.la//g' ./test/Makefile.am
27sed -i 's/..\/modules\/libogg_plugin.la//g' ./test/Makefile.am
28sed -i 's/f(misc_xml_xml)//g' ./test/src/input/demux-run.c
29sed -i 's/f(demux_ogg)//g' ./test/src/input/demux-run.c
30
31# Ensure that we compile with the correct link flags.
32RULE="vlc_demux_libfuzzer_LDADD"
33FUZZ_LDFLAGS="vlc_demux_libfuzzer_LDFLAGS=\${LIB_FUZZING_ENGINE}"
34sed -i "s/${RULE}/${FUZZ_LDFLAGS}\n${RULE}/g" ./test/Makefile.am
35
36RULE="vlc_demux_dec_libfuzzer_LDADD"
37FUZZ_LDFLAGS="vlc_demux_dec_libfuzzer_LDFLAGS=\${LIB_FUZZING_ENGINE}"
38sed -i "s/${RULE}/${FUZZ_LDFLAGS}\n${RULE}/g" ./test/Makefile.am
39
40./bootstrap
41./configure --disable-ogg --disable-oggspots --disable-libxml2 --disable-lua \
42            --disable-shared \
43            --enable-static \
44            --enable-vlc=no \
45            --disable-avcodec \
46            --disable-swscale \
47            --disable-a52 \
48            --disable-xcb \
49            --disable-alsa \
50            --with-libfuzzer
51make V=1 -j$(nproc)
52cp ./test/vlc-demux-dec-libfuzzer $OUT/
53cp ./test/vlc-demux-libfuzzer $OUT/
54