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 18WIRESHARK_BUILD_PATH="$WORK/build" 19mkdir -p "$WIRESHARK_BUILD_PATH" 20 21# Prepare Samples directory 22export SAMPLES_DIR="$WORK/samples" 23mkdir -p "$SAMPLES_DIR" 24cp -a $SRC/wireshark-fuzzdb/samples/* "$SAMPLES_DIR" 25 26# compile static version of libs 27# XXX, with static wireshark linking each fuzzer binary is ~346 MB (just libwireshark.a is 761 MB). 28# XXX, wireshark is not ready for including static plugins into binaries. 29CMAKE_DEFINES="-DENABLE_STATIC=ON -DENABLE_PLUGINS=OFF" 30 31# disable optional dependencies 32CMAKE_DEFINES="$CMAKE_DEFINES -DENABLE_PCAP=OFF -DENABLE_GNUTLS=OFF" 33 34# There is no need to manually disable programs via BUILD_xxx=OFF since the 35# all-fuzzers targets builds the minimum required binaries. However we do have 36# to disable the Qt GUI or else the cmake step will fail. 37CMAKE_DEFINES="$CMAKE_DEFINES -DBUILD_wireshark=OFF" 38 39cd "$WIRESHARK_BUILD_PATH" 40 41cmake -GNinja \ 42 -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \ 43 -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ 44 -DDISABLE_WERROR=ON -DOSS_FUZZ=ON $CMAKE_DEFINES $SRC/wireshark/ 45 46ninja all-fuzzers 47 48$SRC/wireshark/tools/oss-fuzzshark/build.sh all 49