2020-07-19 20:01:12 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
# Copyright 2020 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.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2020-09-02 17:26:26 +00:00
|
|
|
cd $SRC
|
2020-08-14 17:53:56 +00:00
|
|
|
|
2020-12-31 19:23:30 +00:00
|
|
|
wget -qO- https://botan.randombit.net/releases/Botan-2.16.0.tar.xz | tar xJ
|
|
|
|
cd Botan-2.16.0
|
2020-07-19 20:01:12 +00:00
|
|
|
./configure.py --prefix=/usr --cc-bin=$CXX --cc-abi-flags="$CXXFLAGS" \
|
|
|
|
--disable-modules=locking_allocator \
|
|
|
|
--unsafe-fuzzer-mode --build-fuzzers=libfuzzer \
|
|
|
|
--with-fuzzer-lib='FuzzingEngine'
|
2020-09-02 17:26:26 +00:00
|
|
|
make -j$(nproc)
|
2020-07-19 20:01:12 +00:00
|
|
|
make install
|
2020-08-14 17:53:56 +00:00
|
|
|
|
2020-09-02 17:26:26 +00:00
|
|
|
cd $SRC
|
2020-08-14 17:53:56 +00:00
|
|
|
mkdir fuzzing_corpus
|
|
|
|
|
2020-09-02 17:26:26 +00:00
|
|
|
cd $SRC/rnp/src/tests/data
|
|
|
|
find . -type f -print0 | xargs -0 -I bob -- cp bob $SRC/fuzzing_corpus/
|
2020-07-19 20:01:12 +00:00
|
|
|
|
2020-07-27 18:54:20 +00:00
|
|
|
# -DENABLE_SANITIZERS=0 because oss-fuzz will add the sanitizer flags in CFLAGS
|
|
|
|
# See https://github.com/google/oss-fuzz/pull/4189 to explain CMAKE_C_LINK_EXECUTABLE
|
|
|
|
|
2020-09-02 17:26:26 +00:00
|
|
|
cd $SRC
|
2020-07-19 20:01:12 +00:00
|
|
|
mkdir rnp-build
|
|
|
|
cd rnp-build
|
|
|
|
cmake \
|
2020-07-27 18:54:20 +00:00
|
|
|
-DENABLE_SANITIZERS=0 \
|
|
|
|
-DENABLE_FUZZERS=1 \
|
2020-07-19 20:01:12 +00:00
|
|
|
-DCMAKE_C_COMPILER=$CC \
|
|
|
|
-DCMAKE_CXX_COMPILER=$CXX \
|
2020-07-27 18:54:20 +00:00
|
|
|
-DCMAKE_C_LINK_EXECUTABLE="$CXX <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" \
|
2020-07-19 20:01:12 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
|
|
-DBUILD_SHARED_LIBS=on \
|
|
|
|
-DBUILD_TESTING=off \
|
2020-07-27 18:54:20 +00:00
|
|
|
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
|
2020-09-02 17:26:26 +00:00
|
|
|
$SRC/rnp
|
|
|
|
make -j$(nproc)
|
2020-07-19 20:01:12 +00:00
|
|
|
|
2020-09-02 17:26:26 +00:00
|
|
|
FUZZERS=`find src/fuzzing -maxdepth 1 -type f -name "fuzz_*" -exec basename {} \;`
|
|
|
|
printf "Detected fuzzers: \n$FUZZERS\n"
|
2020-07-19 20:01:12 +00:00
|
|
|
for f in $FUZZERS; do
|
|
|
|
cp src/fuzzing/$f "${OUT}/"
|
2020-09-06 15:03:05 +00:00
|
|
|
patchelf --set-rpath '$ORIGIN/lib' "${OUT}/$f" || echo "patchelf failed with $?, ignoring."
|
2020-09-02 17:26:26 +00:00
|
|
|
zip -j -r "${OUT}/${f}_seed_corpus.zip" $SRC/fuzzing_corpus/
|
2020-07-19 20:01:12 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p "${OUT}/lib"
|
2021-03-09 14:06:57 +00:00
|
|
|
cp src/lib/librnp.so.0 "${OUT}/lib/"
|
2020-12-31 19:23:30 +00:00
|
|
|
cp /usr/lib/libbotan-2.so.16 "${OUT}/lib/"
|
2021-08-23 17:11:11 +00:00
|
|
|
cp /lib/x86_64-linux-gnu/libjson-c.so.* "${OUT}/lib/"
|