From 4ef2d5c359d305e46b8ded3585a9f66c24f17930 Mon Sep 17 00:00:00 2001 From: Randy Date: Tue, 26 May 2020 19:26:42 +0200 Subject: [PATCH] [stb] extend code coverage for stb_image (#3784) * [stb] extend code coverage for stb_image * remove wget's from build.sh * add wget's to Dockerfile * fix Dockerfile --- projects/stb/Dockerfile | 7 +++++++ projects/stb/build.sh | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/projects/stb/Dockerfile b/projects/stb/Dockerfile index 30b91b582..89129f409 100644 --- a/projects/stb/Dockerfile +++ b/projects/stb/Dockerfile @@ -16,9 +16,16 @@ FROM gcr.io/oss-fuzz-base/base-builder +RUN apt-get update && \ + apt-get install -y wget tar + MAINTAINER randy408@protonmail.com RUN git clone --depth 1 https://github.com/nothings/stb.git +RUN wget -O $SRC/stb/gif.tar.gz https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/imagetestsuite/imagetestsuite-gif-1.00.tar.gz +RUN wget -O $SRC/stb/jpg.tar.gz https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/imagetestsuite/imagetestsuite-jpg-1.00.tar.gz +RUN wget -O $SRC/stb/tests/gif.dict https://raw.githubusercontent.com/mirrorer/afl/master/dictionaries/gif.dict &> /dev/null + WORKDIR stb COPY build.sh $SRC/ diff --git a/projects/stb/build.sh b/projects/stb/build.sh index 84fbca338..1cbf4c08b 100644 --- a/projects/stb/build.sh +++ b/projects/stb/build.sh @@ -15,11 +15,27 @@ # ################################################################################ -$CXX $CXXFLAGS -std=c++11 -I. \ - $SRC/stb/tests/stb_png_read_fuzzer.cpp \ +# remove this line when this change is upstreamed +sed '2d' $SRC/stb/tests/stb_png_read_fuzzer.cpp > $SRC/stb/tests/stbi_read_fuzzer.c + +$CXX $CXXFLAGS -std=c++11 -I. -DSTBI_ONLY_PNG \ + $SRC/stb/tests/stbi_read_fuzzer.c \ -o $OUT/stb_png_read_fuzzer $LIB_FUZZING_ENGINE +$CXX $CXXFLAGS -std=c++11 -I. \ + $SRC/stb/tests/stbi_read_fuzzer.c \ + -o $OUT/stbi_read_fuzzer $LIB_FUZZING_ENGINE + find $SRC/stb/tests/pngsuite -name "*.png" | \ xargs zip $OUT/stb_png_read_fuzzer_seed_corpus.zip cp $SRC/stb/tests/stb_png.dict $OUT/stb_png_read_fuzzer.dict + +tar xvzf $SRC/stb/jpg.tar.gz --directory $SRC/stb/tests +tar xvzf $SRC/stb/gif.tar.gz --directory $SRC/stb/tests + +find $SRC/stb/tests -name "*.png" -o -name "*.jpg" -o -name ".gif" | \ + xargs zip $OUT/stbi_read_fuzzer_seed_corpus.zip + +echo "" >> $SRC/stb/tests/gif.dict +cat $SRC/stb/tests/gif.dict $SRC/stb/tests/stb_png.dict > $OUT/stbi_read_fuzzer.dict