<commit_before>#!/bin/bash -eu
# Copyright 2017 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.
#
################################################################################

./configure --prefix="$WORK" --disable-shared --disable-docs
make "-j$(nproc)"
make install

$CXX $CXXFLAGS -std=c++11 -I"$WORK/include/ImageMagick-7" "$SRC/encoder_list.cc" \
    -o "$WORK/encoder_list" \
    -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
    "$WORK/lib/libMagick++-7.Q16HDRI.a" \
    "$WORK/lib/libMagickWand-7.Q16HDRI.a" \
    "$WORK/lib/libMagickCore-7.Q16HDRI.a"

for f in $SRC/*_fuzzer.cc; do
    fuzzer=$(basename "$f" _fuzzer.cc)
    # encoder_fuzzer is special
    if [ "$fuzzer" = "encoder" ]; then
        continue
    fi
    $CXX $CXXFLAGS -std=c++11 -I"$WORK/include/ImageMagick-7" \
        "$f" -o "$OUT/${fuzzer}_fuzzer" \
        -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
        -lFuzzingEngine "$WORK/lib/libMagick++-7.Q16HDRI.a" \
        "$WORK/lib/libMagickWand-7.Q16HDRI.a" "$WORK/lib/libMagickCore-7.Q16HDRI.a"
done

for encoder in $("$WORK/encoder_list"); do
    $CXX $CXXFLAGS -std=c++11 -I"$WORK/include/ImageMagick-7" \
        "$SRC/encoder_fuzzer.cc" -o "$OUT/encoder_${encoder,,}_fuzzer" \
        -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
        "-DFUZZ_IMAGEMAGICK_ENCODER=$encoder" \
        -lFuzzingEngine "$WORK/lib/libMagick++-7.Q16HDRI.a" \
        "$WORK/lib/libMagickWand-7.Q16HDRI.a" "$WORK/lib/libMagickCore-7.Q16HDRI.a"
done

mkdir afl_testcases
(cd afl_testcases; tar xvf "$SRC/afl_testcases.tgz")
for format in gif jpg png bmp ico webp tif; do
    mkdir $format
    find afl_testcases -type f -name '*.'$format -exec mv -n {} $format/ \;
    zip -rj $format.zip $format/
    cp $format.zip "$OUT/encoder_${format}_seed_corpus.zip"
done<commit_msg>[imagemagick] Fix seed corpus archive name.<commit_after>#!/bin/bash -eu
# Copyright 2017 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.
#
################################################################################

./configure --prefix="$WORK" --disable-shared --disable-docs
make "-j$(nproc)"
make install

$CXX $CXXFLAGS -std=c++11 -I"$WORK/include/ImageMagick-7" "$SRC/encoder_list.cc" \
    -o "$WORK/encoder_list" \
    -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
    "$WORK/lib/libMagick++-7.Q16HDRI.a" \
    "$WORK/lib/libMagickWand-7.Q16HDRI.a" \
    "$WORK/lib/libMagickCore-7.Q16HDRI.a"

for f in $SRC/*_fuzzer.cc; do
    fuzzer=$(basename "$f" _fuzzer.cc)
    # encoder_fuzzer is special
    if [ "$fuzzer" = "encoder" ]; then
        continue
    fi
    $CXX $CXXFLAGS -std=c++11 -I"$WORK/include/ImageMagick-7" \
        "$f" -o "$OUT/${fuzzer}_fuzzer" \
        -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
        -lFuzzingEngine "$WORK/lib/libMagick++-7.Q16HDRI.a" \
        "$WORK/lib/libMagickWand-7.Q16HDRI.a" "$WORK/lib/libMagickCore-7.Q16HDRI.a"
done

for encoder in $("$WORK/encoder_list"); do
    $CXX $CXXFLAGS -std=c++11 -I"$WORK/include/ImageMagick-7" \
        "$SRC/encoder_fuzzer.cc" -o "$OUT/encoder_${encoder,,}_fuzzer" \
        -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
        "-DFUZZ_IMAGEMAGICK_ENCODER=$encoder" \
        -lFuzzingEngine "$WORK/lib/libMagick++-7.Q16HDRI.a" \
        "$WORK/lib/libMagickWand-7.Q16HDRI.a" "$WORK/lib/libMagickCore-7.Q16HDRI.a"
done

mkdir afl_testcases
(cd afl_testcases; tar xvf "$SRC/afl_testcases.tgz")
for format in gif jpg png bmp ico webp tif; do
    mkdir $format
    find afl_testcases -type f -name '*.'$format -exec mv -n {} $format/ \;
    zip -rj $format.zip $format/
    cp $format.zip "$OUT/encoder_${format}_fuzzer_seed_corpus.zip"
done
{'fraction_non_alphanumeric': 0.1712777191129884, 'fraction_numerical': 0.022386483632523758, 'mean_word_length': 3.549471661863593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6619934', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1739, 'n_words': 390}