2017-04-15 23:22:54 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
# Copyright 2017 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.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2018-04-22 15:35:07 +00:00
|
|
|
WIRESHARK_BUILD_PATH="$WORK/build"
|
|
|
|
mkdir -p "$WIRESHARK_BUILD_PATH"
|
|
|
|
|
2017-04-15 23:22:54 +00:00
|
|
|
export WIRESHARK_INSTALL_PATH="$WORK/install"
|
|
|
|
mkdir -p "$WIRESHARK_INSTALL_PATH"
|
|
|
|
|
2017-04-18 21:05:54 +00:00
|
|
|
# Prepare Samples directory
|
2017-04-24 16:57:53 +00:00
|
|
|
export SAMPLES_DIR="$WORK/samples"
|
2017-04-18 21:05:54 +00:00
|
|
|
mkdir -p "$SAMPLES_DIR"
|
|
|
|
cp -a $SRC/wireshark-fuzzdb/samples/* "$SAMPLES_DIR"
|
|
|
|
|
2017-04-15 23:22:54 +00:00
|
|
|
# compile static version of libs
|
2018-04-22 15:35:07 +00:00
|
|
|
# XXX, with static wireshark linking each fuzzer binary is ~338 MB (just libwireshark.a is 623 MBs).
|
2017-04-15 23:22:54 +00:00
|
|
|
# XXX, wireshark is not ready for including static plugins into binaries.
|
2018-04-22 15:35:07 +00:00
|
|
|
CMAKE_DEFINES="-DENABLE_STATIC=ON -DENABLE_PLUGINS=OFF"
|
2017-04-15 23:22:54 +00:00
|
|
|
|
|
|
|
# disable optional dependencies
|
2018-04-22 15:35:07 +00:00
|
|
|
CMAKE_DEFINES="$CMAKE_DEFINES -DENABLE_PCAP=OFF -DENABLE_GNUTLS=OFF"
|
2017-04-15 23:22:54 +00:00
|
|
|
|
|
|
|
# need only libs, disable programs
|
2018-04-22 15:35:07 +00:00
|
|
|
# TODO, add something like --without-extcap, which would disable all extcap binaries
|
|
|
|
CMAKE_DEFINES="$CMAKE_DEFINES -DBUILD_wireshark=OFF -DBUILD_tshark=OFF -DBUILD_sharkd=OFF \
|
|
|
|
-DBUILD_dumpcap=OFF -DBUILD_capinfos=OFF -DBUILD_captype=OFF -DBUILD_randpkt=OFF -DBUILD_dftest=OFF \
|
|
|
|
-DBUILD_editcap=OFF -DBUILD_mergecap=OFF -DBUILD_reordercap=OFF -DBUILD_text2pcap=OFF \
|
|
|
|
-DBUILD_fuzzshark=OFF \
|
|
|
|
-DBUILD_androiddump=OFF -DBUILD_randpktdump=OFF -DBUILD_udpdump=OFF \
|
2017-04-15 23:22:54 +00:00
|
|
|
"
|
|
|
|
|
2017-04-17 20:26:46 +00:00
|
|
|
# Fortify and asan don't like each other ... :(
|
2018-04-22 15:35:07 +00:00
|
|
|
# TODO, right now -D_FORTIFY_SOURCE=2 is not added in cmake builds.
|
|
|
|
# sed -i '/AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK/d' configure.ac
|
|
|
|
|
|
|
|
cd "$WIRESHARK_BUILD_PATH"
|
|
|
|
|
|
|
|
cmake -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \
|
|
|
|
-DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
|
|
|
|
-DCMAKE_INSTALL_PREFIX="$WIRESHARK_INSTALL_PATH" $CMAKE_DEFINES -DDISABLE_WERROR=ON $SRC/wireshark/
|
2017-04-15 23:22:54 +00:00
|
|
|
|
2018-04-22 15:35:07 +00:00
|
|
|
# disable leak checks, lemon is build with ASAN, and it leaks memory during building.
|
|
|
|
export ASAN_OPTIONS="detect_leaks=0"
|
2017-04-15 23:22:54 +00:00
|
|
|
make "-j$(nproc)"
|
|
|
|
make install
|
2018-04-22 15:35:07 +00:00
|
|
|
|
|
|
|
# make install didn't install config.h, install it manually
|
|
|
|
cp "$WIRESHARK_BUILD_PATH/config.h" "$WIRESHARK_INSTALL_PATH/include/wireshark/"
|
|
|
|
|
2017-04-24 16:57:53 +00:00
|
|
|
$SRC/wireshark/tools/oss-fuzzshark/build.sh all
|