@@ -5,9 +5,14 @@ in_oss_fuzz()
55 test -n " $FUZZING_ENGINE "
66}
77
8- echo " Running cryptsetup OSS-Fuzz build script."
9- env
10- set -ex
8+ last_commit ()
9+ {
10+ echo " $( git -C " $1 " log --format=" %h %s" -n 1) ($1 )"
11+ }
12+
13+ echo " Running cryptsetup OSS-Fuzz build script for ${SANITIZER:- address} sanitizer."
14+ # env ; set -x
15+ set -e
1116XPWD=" $( pwd) "
1217
1318export LC_CTYPE=C.UTF-8
@@ -36,6 +41,7 @@ mkdir -p $OUT
3641mkdir -p $DEPS_PATH
3742cd $SRC
3843
44+ echo " Installing dependencies"
3945LIBFUZZER_PATCH=" $XPWD /unpoison-mutated-buffers-from-libfuzzer.patch"
4046in_oss_fuzz && LIBFUZZER_PATCH=" $XPWD /cryptsetup/tests/fuzz/unpoison-mutated-buffers-from-libfuzzer.patch"
4147
@@ -44,20 +50,40 @@ in_oss_fuzz && apt-get update && apt-get install -y \
4450 sharutils gettext expect keyutils ninja-build \
4551 bison flex
4652
47- [ ! -d zlib ] && git clone --depth 1 https://github.com/madler/zlib.git
53+ echo " Cloning git repositories"
54+ # FIXME: temporary use branch master instead of develop
55+ [ ! -d zlib ] && git clone -q --depth 1 --branch master https://github.com/madler/zlib.git
56+ last_commit zlib
57+
4858# Upstream repo has disabled cloning https://git.tukaani.org/xz.git
49- [ ! -d xz ] && git clone --depth 1 https://github.com/tukaani-project/xz
50- [ ! -d json-c ] && git clone --depth 1 https://github.com/json-c/json-c.git
51- [ ! -d lvm2 ] && git clone --depth 1 https://gitlab.com/lvmteam/lvm2
52- [ ! -d popt ] && git clone --depth 1 https://github.com/rpm-software-management/popt.git
59+ [ ! -d xz ] && git clone -q --depth 1 https://github.com/tukaani-project/xz
60+ last_commit xz
61+
62+ [ ! -d json-c ] && git clone -q --depth 1 https://github.com/json-c/json-c.git
63+ last_commit json-c
64+
65+ [ ! -d lvm2 ] && git clone -q --depth 1 https://gitlab.com/lvmteam/lvm2
66+ last_commit lvm2
67+
68+ [ ! -d popt ] && git clone -q --depth 1 https://github.com/rpm-software-management/popt.git
69+ last_commit popt
70+
5371# FIXME: temporary fix until libprotobuf stops shuffling C++ requirements
5472# [ ! -d libprotobuf-mutator ] && git clone --depth 1 https://github.com/google/libprotobuf-mutator.git \
55- [ ! -d libprotobuf-mutator ] && git clone --depth 1 --branch v1.1 https://github.com/google/libprotobuf-mutator.git \
56- && [ " $SANITIZER " == " memory" ] && ( cd libprotobuf-mutator; patch -p1 < $LIBFUZZER_PATCH )
57- [ ! -d openssl ] && git clone --depth 1 https://github.com/openssl/openssl
58- [ ! -d util-linux ] && git clone --depth 1 https://github.com/util-linux/util-linux
59- [ ! -d cryptsetup_fuzzing ] && git clone --depth 1 https://gitlab.com/cryptsetup/cryptsetup_fuzzing.git
73+ [ ! -d libprotobuf-mutator ] && git clone -q --depth 1 --branch v1.1 -c advice.detachedHead=false \
74+ https://github.com/google/libprotobuf-mutator.git &&
75+ [ " $SANITIZER " == " memory" ] && ( cd libprotobuf-mutator; patch -p1 < $LIBFUZZER_PATCH )
76+ last_commit libprotobuf-mutator
77+
78+ [ ! -d openssl ] && git clone -q --depth 1 https://github.com/openssl/openssl
79+ last_commit openssl
80+
81+ [ ! -d util-linux ] && git clone -q --depth 1 https://github.com/util-linux/util-linux
82+ last_commit util-linux
83+
84+ [ ! -d cryptsetup_fuzzing ] && git clone -q --depth 1 https://gitlab.com/cryptsetup/cryptsetup_fuzzing.git
6085
86+ echo " Building libraries from git"
6187cd openssl
6288./Configure --prefix=" $DEPS_PATH " --libdir=lib no-shared no-module no-asm
6389make build_generated
@@ -128,6 +154,7 @@ cd external.protobuf;
128154cp -Rf bin lib include " $DEPS_PATH " ;
129155cd ../../..
130156
157+ echo " Building cryptsetup fuzzers"
131158if in_oss_fuzz; then
132159 mkdir -p cryptsetup/tests/fuzz/build
133160 ln -s ../../../../static_lib_deps cryptsetup/tests/fuzz/build/static_lib_deps
140167make clean
141168make -j fuzz-targets
142169
170+ echo " Installing fuzzers"
143171for fuzzer in $ENABLED_FUZZERS ; do
144172 cp tests/fuzz/$fuzzer $OUT
145173 cp $SRC /cryptsetup_fuzzing/${fuzzer} _seed_corpus.zip $OUT
0 commit comments