diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2021-01-02 15:06:22 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-02 16:06:22 -0500 |
commit | 4d33122af1c9905c8e9eb6c946d70abb12dfee3a (patch) | |
tree | 669cc92851d6bd663e5609fd4bab19a203bd440a | |
parent | 2cfafdb095287a032c284a029fff2df78e5b7456 (diff) | |
download | ImageMagick-4d33122af1c9905c8e9eb6c946d70abb12dfee3a.tar.gz |
[OSS-Fuzz] Build fuzzers faster and resolve compiler warnings (#3064)
* use lld instead of GNU ld for linking the fuzzers
The fuzzers link a huge number of symbols (each fuzzer is ~43MB as of
this writing) and GNU ld is wildly slower at this. This change lowers
the build time for all fuzzers by 50% on a 22 core machine.
* == is not a valid comparison for char * in C
This worked anyway since the compiler unified the macro and the string
literal so it compared two identical addresses, but we should do the
comparison correctly.
-rw-r--r-- | Magick++/fuzz/build_fuzzers.sh | 4 | ||||
-rw-r--r-- | Magick++/fuzz/encoder_fuzzer.cc | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/Magick++/fuzz/build_fuzzers.sh b/Magick++/fuzz/build_fuzzers.sh index aefbeef35..29e5e3a28 100644 --- a/Magick++/fuzz/build_fuzzers.sh +++ b/Magick++/fuzz/build_fuzzers.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -MAGICK_COMPILER_FLAGS="$MAGICK_COMPILER_FLAGS -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16" +MAGICK_COMPILER_FLAGS="$MAGICK_COMPILER_FLAGS -fuse-ld=lld -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16" $MAGICK_COMPILER $MAGICK_COMPILER_FLAGS -std=c++11 -I$MAGICK_INCLUDE "$MAGICK_SRC/encoder_list.cc" \ -o "$MAGICK_SRC/encoder_list" $MAGICK_LIBS_NO_FUZZ @@ -40,7 +40,7 @@ for item in $("$MAGICK_SRC/encoder_list"); do $encoder_flags $MAGICK_LIBS echo -e "[libfuzzer]\nclose_fd_mask=3" > "$MAGICK_OUTPUT/encoder_${encoder,,}_fuzzer.options" - + if [ -f "$MAGICK_SRC/dictionaries/${encoder,,}.dict" ]; then cp "$MAGICK_SRC/dictionaries/${encoder,,}.dict" "$MAGICK_OUTPUT/ping_${encoder,,}_fuzzer.dict" cp "$MAGICK_SRC/dictionaries/${encoder,,}.dict" "$MAGICK_OUTPUT/encoder_${encoder,,}_fuzzer.dict" diff --git a/Magick++/fuzz/encoder_fuzzer.cc b/Magick++/fuzz/encoder_fuzzer.cc index b29d7722f..5edcdbb6f 100644 --- a/Magick++/fuzz/encoder_fuzzer.cc +++ b/Magick++/fuzz/encoder_fuzzer.cc @@ -1,4 +1,5 @@ #include <cstdint> +#include <string.h> #include <Magick++/Blob.h> #include <Magick++/Image.h> @@ -19,14 +20,14 @@ static ssize_t EncoderInitializer(const uint8_t *Data, const size_t Size, Magick::Image &image) { - if (FUZZ_ENCODER_INITIALIZER == "interlace") { + if (strcmp(FUZZ_ENCODER_INITIALIZER, "interlace") == 0) { Magick::InterlaceType interlace = (Magick::InterlaceType) *reinterpret_cast<const char *>(Data); if (interlace > Magick::PNGInterlace) return -1; image.interlaceType(interlace); return 1; } - if (FUZZ_ENCODER_INITIALIZER == "png") { + if (strcmp(FUZZ_ENCODER_INITIALIZER, "png") == 0) { image.defineValue("png", "ignore-crc", "1"); } |