1 #!/bin/bash -eu 2 3 MAGICK_COMPILER_FLAGS="$MAGICK_COMPILER_FLAGS -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16" 4 5 $MAGICK_COMPILER $MAGICK_COMPILER_FLAGS -std=c++11 -I$MAGICK_INCLUDE "$MAGICK_SRC/encoder_list.cc" \ 6 -o "$MAGICK_SRC/encoder_list" $MAGICK_LIBS 7 8 for f in $MAGICK_SRC/*_fuzzer.cc; do 9 fuzzer=$(basename "$f" _fuzzer.cc) 10 # encoder_fuzzer and ping_fuzzer are special 11 if [ "$fuzzer" == "encoder" ] || [ "$fuzzer" == "ping" ]; then 12 continue 13 fi 14 $MAGICK_COMPILER $MAGICK_COMPILER_FLAGS -std=c++11 -I$MAGICK_INCLUDE \ 15 "$f" -o "$MAGICK_OUTPUT/${fuzzer}_fuzzer" $MAGICK_LIBS 16 echo -e "[libfuzzer]\nclose_fd_mask=3" > "$MAGICK_OUTPUT/${fuzzer}_fuzzer.options" 17 done 18 19 for item in $("$MAGICK_SRC/encoder_list"); do 20 info=${item:1} 21 encoder=${info%:*} 22 initializer=${info##*:} 23 encoder_flags="-DFUZZ_IMAGEMAGICK_ENCODER=$encoder" 24 if [ "$initializer" != "" ]; then 25 encoder_flags="$encoder_flags -DFUZZ_IMAGEMAGICK_ENCODER_INITIALIZER=$initializer" 26 fi 27 28 $MAGICK_COMPILER $MAGICK_COMPILER_FLAGS -std=c++11 -I$MAGICK_INCLUDE \ 29 "$MAGICK_SRC/ping_fuzzer.cc" -o "$MAGICK_OUTPUT/ping_${encoder,,}_fuzzer" \ 30 $encoder_flags $MAGICK_LIBS 31 32 echo -e "[libfuzzer]\nclose_fd_mask=3" > "$MAGICK_OUTPUT/ping_${encoder,,}_fuzzer.options" 33 34 if [ "${item:0:1}" == "+" ]; then 35 encoder_flags="$encoder_flags -DFUZZ_IMAGEMAGICK_ENCODER_WRITE=1" 36 fi 37 38 $MAGICK_COMPILER $MAGICK_COMPILER_FLAGS -std=c++11 -I$MAGICK_INCLUDE \ 39 "$MAGICK_SRC/encoder_fuzzer.cc" -o "$MAGICK_OUTPUT/encoder_${encoder,,}_fuzzer" \ 40 $encoder_flags $MAGICK_LIBS 41 42 echo -e "[libfuzzer]\nclose_fd_mask=3" > "$MAGICK_OUTPUT/encoder_${encoder,,}_fuzzer.options" 43 44 if [ -f "$MAGICK_SRC/dictionaries/${encoder,,}.dict" ]; then 45 cp "$MAGICK_SRC/dictionaries/${encoder,,}.dict" "$MAGICK_OUTPUT/ping_${encoder,,}_fuzzer.dict" 46 cp "$MAGICK_SRC/dictionaries/${encoder,,}.dict" "$MAGICK_OUTPUT/encoder_${encoder,,}_fuzzer.dict" 47 fi 48 49 if [ $MAGICK_FAST_BUILD -eq 1 ]; then 50 break 51 fi 52 done 53