From a30a76c93fe1fb5e7d5a4c6d1ca957fc16638786 Mon Sep 17 00:00:00 2001 From: Joseph Bisch Date: Wed, 11 Sep 2019 21:33:27 -0400 Subject: [PATCH] Fix irssi build (#2785) --- projects/irssi/Dockerfile | 3 +- projects/irssi/build.sh | 65 ++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/projects/irssi/Dockerfile b/projects/irssi/Dockerfile index c041fc5a2..7d2c69451 100644 --- a/projects/irssi/Dockerfile +++ b/projects/irssi/Dockerfile @@ -16,7 +16,8 @@ FROM gcr.io/oss-fuzz-base/base-builder MAINTAINER joseph.bisch@gmail.com -RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-config libglib2.0-dev libncurses5-dev libssl-dev openssl lynx wget +RUN apt-get update && apt-get install -y pkg-config libncurses5-dev libssl-dev python3-pip +RUN pip3 install -U meson ninja RUN git clone https://github.com/irssi/irssi WORKDIR irssi diff --git a/projects/irssi/build.sh b/projects/irssi/build.sh index 8947e4699..6036b96e2 100644 --- a/projects/irssi/build.sh +++ b/projects/irssi/build.sh @@ -15,41 +15,44 @@ # ################################################################################ -# configure script needs leak checking disabled to not fail -export ASAN_OPTIONS=detect_leaks=0 -./autogen.sh -# TODO: Stop using LIB_FUZZING_ENGINE_DEPRECATED and make this build use -# LIB_FUZZING_ENGINE (see https://github.com/google/oss-fuzz/issues/2317). -./configure --with-perl=no --disable-shared --without-textui --with-fuzzer \ - --with-fuzzer-lib=$LIB_FUZZING_ENGINE_DEPRECATED \ - CC=$CC CXX=$CXX PKG_CONFIG="pkg-config --static" -make clean -make "-j$(nproc)" CFLAGS="-static -DSUPPRESS_PRINTF_FALLBACK $CFLAGS" CXXFLAGS="-static $CXXFLAGS" +# setup +BUILD=$WORK/Build +fuzz_targets=( + src/fe-fuzz/irssi-fuzz + src/fe-fuzz/server-fuzz + src/fe-fuzz/irc/core/event-get-params-fuzz + src/fe-fuzz/fe-common/core/theme-load-fuzz +) + +if [ "$FUZZING_ENGINE" = honggfuzz ]; then + export CC="$SRC"/"$FUZZING_ENGINE"/hfuzz_cc/hfuzz-clang + export CXX="$SRC"/"$FUZZING_ENGINE"/hfuzz_cc/hfuzz-clang++ +fi + +# cleanup +rm -rf "$BUILD" +mkdir -p "$BUILD" + +# Configure the project. +meson "$BUILD" -Dstatic-dependency=yes -Dinstall-glib=force \ + -Dwith-fuzzer=yes -Dwith-fuzzer-lib=$LIB_FUZZING_ENGINE \ + -Dfuzzer-link-language=cpp \ + || ( cat "$BUILD"/meson-logs/meson-log.txt && false ) # now build all fuzz targets +ninja -C "$BUILD" -v "${fuzz_targets[@]}" +( cd "$BUILD" && mv "${fuzz_targets[@]}" "$OUT" ) -export GLIB_CFLAGS="$(pkg-config --static --cflags glib-2.0)" -export GLIB_LIBS="$(pkg-config --static --libs glib-2.0)" +git clone --depth 1 https://github.com/irssi-import/themes theme-load-fuzz_corpus +git clone --depth 1 https://github.com/irssi/irssi-fuzzing-corpora -CORE_LIBS="src/core/libcore.a" -CORE_LIBS="$CORE_LIBS src/lib-config/libirssi_config.a" +find theme-load-fuzz_corpus -mindepth 1 -maxdepth 1 \( -type d -o \! -name \*.theme \) -exec rm -fr {} + -FE_COMMON_LIBS="src/irc/libirc.a" -FE_COMMON_LIBS="$FE_COMMON_LIBS src/irc/core/libirc_core.a" -FE_COMMON_LIBS="$FE_COMMON_LIBS src/fe-common/irc/libfe_common_irc.a" -FE_COMMON_LIBS="$FE_COMMON_LIBS src/fe-common/core/libfe_common_core.a" +zip -q -j "$OUT"/theme-load-fuzz_seed_corpus.zip theme-load-fuzz_corpus/* +zip -q -j "$OUT"/irssi-fuzz_seed_corpus.zip irssi-fuzzing-corpora/irssi-fuzz-corpus/* +zip -q -j "$OUT"/server-fuzz_seed_corpus.zip irssi-fuzzing-corpora/server-fuzz-corpus/* -FE_FUZZ_CFLAGS="-I. -Isrc -Isrc/core/ -Isrc/irc/core/ -Isrc/fe-common/core/" +# get tokens.txt dictionary from irssi/src/fe-fuzz/ +cp src/fe-fuzz/tokens.txt "$OUT"/server-fuzz.dict -for target in irssi irc/core/event-get-params fe-common/core/theme-load; do - ${CXX} ${CXXFLAGS} -DHAVE_CONFIG_H $LIB_FUZZING_ENGINE ${FE_FUZZ_CFLAGS} ${GLIB_CFLAGS} \ - src/fe-fuzz/${target}.o src/fe-text/module-formats.o -lm \ - -Wl,-Bstatic ${FE_COMMON_LIBS} ${CORE_LIBS} -lssl -lcrypto ${GLIB_LIBS} -lgmodule-2.0 -lz \ - -Wl,-Bdynamic -o $OUT/${target##*/}-fuzz -done - -mkdir $SRC/theme-load-fuzz_corpus -wget -r -P $SRC/theme-load-fuzz_corpus -nH --cut-dirs=100 -np -l 1 -A theme https://irssi-import.github.io/themes/ -zip -j $OUT/theme-load-fuzz_seed_corpus.zip $SRC/theme-load-fuzz_corpus/* - -cp $SRC/*.options $SRC/*.dict $OUT/ +cp "$SRC"/*.options "$SRC"/*.dict "$OUT"/