From e4be55dc28479a0ee103e5d65cd00c441feb5ff2 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Fri, 30 Mar 2018 15:05:13 -0400 Subject: Add Encoder fuzzers This also includes a helper "fuzzer" for making a corpus. Point it at an image or folder of images and it will decode those images and write the SkPixmap's bytes to disk, such that the fuzzer will be able to read in those bytes as if it had decoded the image (or gotten it from another source). Bug: skia: Change-Id: Iaf223a39078f2b62908fb47929add5d63f22d973 Reviewed-on: https://skia-review.googlesource.com/117367 Reviewed-by: Leon Scroggins Commit-Queue: Kevin Lubick --- fuzz/oss_fuzz/FuzzJPEGEncoder.cpp | 16 ++++++++++++++++ fuzz/oss_fuzz/FuzzPNGEncoder.cpp | 16 ++++++++++++++++ fuzz/oss_fuzz/FuzzWEBPEncoder.cpp | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 fuzz/oss_fuzz/FuzzJPEGEncoder.cpp create mode 100644 fuzz/oss_fuzz/FuzzPNGEncoder.cpp create mode 100644 fuzz/oss_fuzz/FuzzWEBPEncoder.cpp (limited to 'fuzz/oss_fuzz') diff --git a/fuzz/oss_fuzz/FuzzJPEGEncoder.cpp b/fuzz/oss_fuzz/FuzzJPEGEncoder.cpp new file mode 100644 index 0000000000..3d5ce412e7 --- /dev/null +++ b/fuzz/oss_fuzz/FuzzJPEGEncoder.cpp @@ -0,0 +1,16 @@ +/* + * Copyright 2018 Google, LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../Fuzz.h" + +void fuzz_JPEGEncoder(Fuzz* f); + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size)); + fuzz_JPEGEncoder(&fuzz); + return 0; +} diff --git a/fuzz/oss_fuzz/FuzzPNGEncoder.cpp b/fuzz/oss_fuzz/FuzzPNGEncoder.cpp new file mode 100644 index 0000000000..8e104166cf --- /dev/null +++ b/fuzz/oss_fuzz/FuzzPNGEncoder.cpp @@ -0,0 +1,16 @@ +/* + * Copyright 2018 Google, LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../Fuzz.h" + +void fuzz_PNGEncoder(Fuzz* f); + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size)); + fuzz_PNGEncoder(&fuzz); + return 0; +} diff --git a/fuzz/oss_fuzz/FuzzWEBPEncoder.cpp b/fuzz/oss_fuzz/FuzzWEBPEncoder.cpp new file mode 100644 index 0000000000..f1da38d6ca --- /dev/null +++ b/fuzz/oss_fuzz/FuzzWEBPEncoder.cpp @@ -0,0 +1,16 @@ +/* + * Copyright 2018 Google, LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../Fuzz.h" + +void fuzz_WEBPEncoder(Fuzz* f); + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size)); + fuzz_WEBPEncoder(&fuzz); + return 0; +} -- cgit v1.2.3