From 09a42b2f9cadcd3736b67d52b0a9391f1a65acaf Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 15 Jan 2018 17:14:46 -0600 Subject: [PATCH] try building the fuzzers without libfuzzer --- .travis/build_fuzzers.sh | 46 ++++++++++++-------------- Magick++/fuzz/crop_fuzzer.cc | 2 ++ Magick++/fuzz/encoder_fuzzer.cc | 2 ++ Magick++/fuzz/enhance_fuzzer.cc | 2 ++ Magick++/fuzz/huffman_decode_fuzzer.cc | 2 ++ Magick++/fuzz/rotate_fuzzer.cc | 2 ++ Magick++/fuzz/travis.cc | 6 ++++ 7 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 Magick++/fuzz/travis.cc diff --git a/.travis/build_fuzzers.sh b/.travis/build_fuzzers.sh index 71b3d6e10..e5642d8f5 100755 --- a/.travis/build_fuzzers.sh +++ b/.travis/build_fuzzers.sh @@ -4,32 +4,28 @@ set -e set -x MAGICKINCLUDE="appdir/usr/include/ImageMagick-7" -MAGICKFUZZERLIBS="-Lappdir/usr/lib -lz -lpng -lfontconfig -lxcb -lX11 -lXext -lbz2 -ljpeg -ljbig -lIlmImf -ldjvulibre -ltiff -llqr-1 -lwmf -lwmflite -lraqm -lxml2 -llzma -llcms2 -lpthread -lfreetype -lMagick++-7.Q16 -lMagickWand-7.Q16 -lMagickCore-7.Q16 libfuzzer/libFuzzer.a" +MAGICKFUZZERLIBS="-Lappdir/usr/lib -lz -lpng -lfontconfig -lxcb -lX11 -lXext -lbz2 -ljpeg -ljbig -lIlmImf -ldjvulibre -ltiff -llqr-1 -lwmf -lwmflite -lraqm -lxml2 -llzma -llcms2 -lpthread -lfreetype -lMagick++-7.Q16 -lMagickWand-7.Q16 -lMagickCore-7.Q16" -# Checkout and build libFuzzer -svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer libfuzzer -pushd libfuzzer -./build.sh -popd +# only compile this against clang +if [[ "$CC" == 'clang' ]]; then + clang++ -std=c++11 -I$MAGICKINCLUDE "Magick++/fuzz/encoder_list.cc" \ + -o "encoder_list" \ + -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -DBUILD_TRAVIS=1 $MAGICKFUZZERLIBS + for f in Magick++/fuzz/*_fuzzer.cc; do + fuzzer=$(basename "$f" _fuzzer.cc) + # encoder_fuzzer is special + if [ "$fuzzer" = "encoder" ]; then + continue + fi + clang++ -std=c++11 -I$MAGICKINCLUDE \ + "$f" -o "${fuzzer}_fuzzer" \ + -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -DBUILD_TRAVIS=1 $MAGICKFUZZERLIBS + done -clang++ -std=c++11 -I$MAGICKINCLUDE "Magick++/fuzz/encoder_list.cc" \ - -o "encoder_list" \ - -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 $MAGICKFUZZERLIBS - -for f in Magick++/fuzz/*_fuzzer.cc; do - fuzzer=$(basename "$f" _fuzzer.cc) - # encoder_fuzzer is special - if [ "$fuzzer" = "encoder" ]; then - continue - fi + # Build one encoder to confirm it works clang++ -std=c++11 -I$MAGICKINCLUDE \ - "$f" -o "${fuzzer}_fuzzer" \ - -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 $MAGICKFUZZERLIBS -done - -# Build one encoder to confirm it works -clang++ -std=c++11 -I$MAGICKINCLUDE \ - "Magick++/fuzz/encoder_fuzzer.cc" -o "encoder_wmf_fuzzer" \ - -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 \ - "-DFUZZ_IMAGEMAGICK_ENCODER=WMF" $MAGICKFUZZERLIBS + "Magick++/fuzz/encoder_fuzzer.cc" -o "encoder_wmf_fuzzer" \ + -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -DBUILD_TRAVIS=1 \ + "-DFUZZ_IMAGEMAGICK_ENCODER=WMF" $MAGICKFUZZERLIBS +fi diff --git a/Magick++/fuzz/crop_fuzzer.cc b/Magick++/fuzz/crop_fuzzer.cc index 2b181dc59..d25714839 100644 --- a/Magick++/fuzz/crop_fuzzer.cc +++ b/Magick++/fuzz/crop_fuzzer.cc @@ -24,3 +24,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { image.crop(Magick::Geometry(Width, Height)); return 0; } + +#include "travis.cc" diff --git a/Magick++/fuzz/encoder_fuzzer.cc b/Magick++/fuzz/encoder_fuzzer.cc index 2d74f5e5a..dc9b3ff18 100644 --- a/Magick++/fuzz/encoder_fuzzer.cc +++ b/Magick++/fuzz/encoder_fuzzer.cc @@ -35,3 +35,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { #endif return 0; } + +#include "travis.cc" diff --git a/Magick++/fuzz/enhance_fuzzer.cc b/Magick++/fuzz/enhance_fuzzer.cc index 6d3b44de0..9ef8a3961 100644 --- a/Magick++/fuzz/enhance_fuzzer.cc +++ b/Magick++/fuzz/enhance_fuzzer.cc @@ -16,3 +16,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { } return 0; } + +#include "travis.cc" diff --git a/Magick++/fuzz/huffman_decode_fuzzer.cc b/Magick++/fuzz/huffman_decode_fuzzer.cc index c4598f2a9..b53788895 100644 --- a/Magick++/fuzz/huffman_decode_fuzzer.cc +++ b/Magick++/fuzz/huffman_decode_fuzzer.cc @@ -19,3 +19,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { (void) MagickCore::DestroyExceptionInfo(exceptionInfo); return 0; } + +#include "travis.cc" diff --git a/Magick++/fuzz/rotate_fuzzer.cc b/Magick++/fuzz/rotate_fuzzer.cc index 0928db638..d4a03a7cc 100644 --- a/Magick++/fuzz/rotate_fuzzer.cc +++ b/Magick++/fuzz/rotate_fuzzer.cc @@ -23,3 +23,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { image.rotate(Degrees); return 0; } + +#include "travis.cc" diff --git a/Magick++/fuzz/travis.cc b/Magick++/fuzz/travis.cc new file mode 100644 index 000000000..11ee54735 --- /dev/null +++ b/Magick++/fuzz/travis.cc @@ -0,0 +1,6 @@ +#if BUILD_TRAVIS +int main() +{ + return LLVMFuzzerTestOneInput(0, 0); +} +#endif // BUILD_TRAVIS -- 2.40.0