• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2017 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
18UNRAR_DEFINES="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DRAR_SMP -DRARDLL -DSILENT -DNOVOLUME"
19UNRAR_WNOS="-Wno-logical-op-parentheses -Wno-switch -Wno-dangling-else"
20UNRAR_SRC_DIR="$SRC/unrar"
21
22# See: https://crbug.com/oss-fuzz/19333#c3
23CFLAGS="$CFLAGS -fno-sanitize=enum"
24CXXFLAGS="$CXXFLAGS -fno-sanitize=enum"
25
26# build 'lib'. This builds libunrar.a and libunrar.so
27# -fPIC is required for successful compilation.
28make CXX=$CXX CXXFLAGS="$CXXFLAGS -fPIC $UNRAR_DEFINES $UNRAR_WNOS" \
29  -C $UNRAR_SRC_DIR lib
30
31# remove the .so file so that the linker links unrar statically.
32rm -v $UNRAR_SRC_DIR/libunrar.so
33
34# build fuzzer
35$CXX $CXXFLAGS -I. $UNRAR_SRC_DIR/unrar_fuzzer.cc -o $OUT/unrar_fuzzer \
36     $UNRAR_DEFINES $LIB_FUZZING_ENGINE -L$UNRAR_SRC_DIR -lunrar
37