aboutsummaryrefslogtreecommitdiff
path: root/projects/leptonica
diff options
context:
space:
mode:
authorAdamKorcz <44787359+AdamKorcz@users.noreply.github.com>2020-04-27 17:31:14 +0100
committerGitHub <noreply@github.com>2020-04-27 09:31:14 -0700
commit924ff1cd98d3201359a8e290edd128d3bcbc431b (patch)
tree9ef6a251a1742e94103b7f87680dd2d9f59226e8 /projects/leptonica
parente0170c273df5324c0a78b20c22bd4bbd2e9589f4 (diff)
downloadoss-fuzz-924ff1cd98d3201359a8e290edd128d3bcbc431b.tar.gz
[Leptonica] Added fuzzer with corpus (#3712)
* [Leptonica] Added fuzzer with corpus * Updated fuzzer to not create and read from a file * Updated fuzzer to not create and read from a file * Added check to see if pixReadMem is NULL
Diffstat (limited to 'projects/leptonica')
-rw-r--r--projects/leptonica/Dockerfile3
-rwxr-xr-xprojects/leptonica/build.sh17
-rw-r--r--projects/leptonica/corpus.zipbin0 -> 99986 bytes
-rw-r--r--projects/leptonica/enhance_fuzzer.cc49
4 files changed, 68 insertions, 1 deletions
diff --git a/projects/leptonica/Dockerfile b/projects/leptonica/Dockerfile
index 64fe26bee..fd35d71a4 100644
--- a/projects/leptonica/Dockerfile
+++ b/projects/leptonica/Dockerfile
@@ -27,4 +27,5 @@ RUN git clone https://www.cl.cam.ac.uk/~mgk25/git/jbigkit jbigkit
RUN git clone --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo libjpeg-turbo
RUN git clone --depth 1 https://github.com/facebook/zstd zstd
WORKDIR leptonica
-COPY build.sh pixa_recog_fuzzer.cc pix_rotate_shear_fuzzer.cc $SRC/
+COPY build.sh pixa_recog_fuzzer.cc enhance_fuzzer.cc \
+ pix_rotate_shear_fuzzer.cc corpus.zip $SRC/
diff --git a/projects/leptonica/build.sh b/projects/leptonica/build.sh
index 2f55342dd..132e65d58 100755
--- a/projects/leptonica/build.sh
+++ b/projects/leptonica/build.sh
@@ -130,4 +130,21 @@ $CXX $CXXFLAGS -std=c++11 -I"$WORK/include" \
"$WORK/lib/libz.a" \
$LIB_FUZZING_ENGINE
+$CXX $CXXFLAGS -std=c++11 -I"$WORK/include" \
+ "$SRC/enhance_fuzzer.cc" -o "$OUT/enhance_fuzzer" \
+ -Isrc/ \
+ "$WORK/lib/liblept.a" \
+ "$WORK/lib/libtiff.a" \
+ "$WORK/lib/libwebp.a" \
+ "$WORK/lib/libpng.a" \
+ "$WORK/lib/libjpeg.a" \
+ "$WORK/lib/libjbig.a" \
+ "$WORK/lib/libzstd.a" \
+ "$WORK/lib/libz.a" \
+ $LIB_FUZZING_ENGINE
+
+
+cp $SRC/corpus.zip /out/pix_rotate_shear_fuzzer_seed_corpus.zip
+cp $SRC/corpus.zip /out/enhance_fuzzer_seed_corpus.zip
+
cd $SRC/leptonica/prog/recog/sets && zip pixa_recog_fuzzer_seed_corpus.zip test01.pa && mv pixa_recog_fuzzer_seed_corpus.zip /out/
diff --git a/projects/leptonica/corpus.zip b/projects/leptonica/corpus.zip
new file mode 100644
index 000000000..61a08f0d2
--- /dev/null
+++ b/projects/leptonica/corpus.zip
Binary files differ
diff --git a/projects/leptonica/enhance_fuzzer.cc b/projects/leptonica/enhance_fuzzer.cc
new file mode 100644
index 000000000..5392c24d7
--- /dev/null
+++ b/projects/leptonica/enhance_fuzzer.cc
@@ -0,0 +1,49 @@
+/*
+# Copyright 2020 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.
+#
+################################################################################
+*/
+
+#include "string.h"
+#include "allheaders.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+extern "C" int
+LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ if(size<3) return 0;
+ PIX *pix, *pix0, *pix1, *pix2, *pix3, *pix4;
+
+ pix = pixReadMem(data, size);
+ if(pix==NULL) return 0;
+
+ pix0 = pixModifyHue(NULL, pix, 0.01 + 0.05 * 1);
+ pix1 = pixModifySaturation(NULL, pix, -0.9 + 0.1 * 1);
+ pix2 = pixMosaicColorShiftRGB(pix, -0.1, 0.0, 0.0, 0.0999, 1);
+ pix3 = pixMultConstantColor(pix, 0.7, 0.4, 1.3);
+ pix4 = pixUnsharpMasking(pix, 3, 0.01 + 0.15 * 1);
+
+ pixDestroy(&pix);
+ pixDestroy(&pix0);
+ pixDestroy(&pix1);
+ pixDestroy(&pix2);
+ pixDestroy(&pix3);
+ pixDestroy(&pix4);
+ return 0;
+}