Fix irssi build (#2785)

This commit is contained in:
Joseph Bisch 2019-09-11 21:33:27 -04:00 committed by jonathanmetzman
parent 7b4370c2fb
commit a30a76c93f
2 changed files with 36 additions and 32 deletions

View File

@ -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

View File

@ -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"/