diff options
author | Kevin Lubick <kjlubick@google.com> | 2018-12-14 11:42:53 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-12-14 17:11:56 +0000 |
commit | ec1c620316685cb0e9f41dbbef805e74c61142a8 (patch) | |
tree | 1ca4979768a2c670958932de0a16e3747a75a196 /fuzz | |
parent | eb82b5a3ee917654de6a60907e40ed8d3ef3d739 (diff) | |
download | platform_external_skqp-ec1c620316685cb0e9f41dbbef805e74c61142a8.tar.gz platform_external_skqp-ec1c620316685cb0e9f41dbbef805e74c61142a8.tar.bz2 platform_external_skqp-ec1c620316685cb0e9f41dbbef805e74c61142a8.zip |
Avoid system fonts when fuzzing
This should make reproducing certain fuzzes easier between oss-fuzz
and a typical dev's desktop.
This was the most straight-forward way I could think of to
accomplish this. An ideal solution would "compile" a set of
fonts that was not the test set and embed it, but I lack the
domain knowledge to craft such a set.
If this method works ok, we can explore making the font set
more robust and varied.
Bug: 818769
Change-Id: I03eb2bc316caf7aec3ffa88e59ff29d76c8557ec
Reviewed-on: https://skia-review.googlesource.com/c/177800
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp | 3 | ||||
-rw-r--r-- | fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp | 3 | ||||
-rw-r--r-- | fuzz/oss_fuzz/FuzzNullCanvas.cpp | 3 | ||||
-rw-r--r-- | fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp | 3 | ||||
-rw-r--r-- | fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp | 3 |
5 files changed, 15 insertions, 0 deletions
diff --git a/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp b/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp index f9d9598892..7ae7870ee8 100644 --- a/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp +++ b/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp @@ -9,8 +9,10 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkData.h" +#include "SkFontMgrPriv.h" #include "SkImageFilter.h" #include "SkPaint.h" +#include "SkTestFontMgr.h" void FuzzImageFilterDeserialize(sk_sp<SkData> bytes) { const int BitmapSize = 24; @@ -39,6 +41,7 @@ void FuzzImageFilterDeserialize(sk_sp<SkData> bytes) { #if defined(IS_FUZZING_WITH_LIBFUZZER) extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr; auto bytes = SkData::MakeWithoutCopy(data, size); FuzzImageFilterDeserialize(bytes); return 0; diff --git a/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp b/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp index 539e989f56..5a6f389bee 100644 --- a/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp +++ b/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp @@ -6,6 +6,8 @@ */ #include "../Fuzz.h" +#include "SkTestFontMgr.h" +#include "SkFontMgrPriv.h" void fuzz_MockGPUCanvas(Fuzz* f); @@ -18,6 +20,7 @@ extern "C" { } int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr; auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size)); fuzz_MockGPUCanvas(&fuzz); return 0; diff --git a/fuzz/oss_fuzz/FuzzNullCanvas.cpp b/fuzz/oss_fuzz/FuzzNullCanvas.cpp index 37f32881a9..2363af8dab 100644 --- a/fuzz/oss_fuzz/FuzzNullCanvas.cpp +++ b/fuzz/oss_fuzz/FuzzNullCanvas.cpp @@ -6,10 +6,13 @@ */ #include "../Fuzz.h" +#include "SkTestFontMgr.h" +#include "SkFontMgrPriv.h" void fuzz_NullCanvas(Fuzz* f); extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr; auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size)); fuzz_NullCanvas(&fuzz); return 0; diff --git a/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp b/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp index 24d74a5cd6..8038cf5a98 100644 --- a/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp +++ b/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp @@ -6,10 +6,13 @@ */ #include "../Fuzz.h" +#include "SkTestFontMgr.h" +#include "SkFontMgrPriv.h" void fuzz_RasterN32Canvas(Fuzz* f); extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr; auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size)); fuzz_RasterN32Canvas(&fuzz); return 0; diff --git a/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp b/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp index de68bcc5ff..6b82c79358 100644 --- a/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp +++ b/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp @@ -6,9 +6,11 @@ */ #include "SkCanvas.h" +#include "SkFontMgrPriv.h" #include "SkPaint.h" #include "SkReadBuffer.h" #include "SkSurface.h" +#include "SkTestFontMgr.h" #include "SkTextBlobPriv.h" void FuzzTextBlobDeserialize(SkReadBuffer& buf) { @@ -27,6 +29,7 @@ void FuzzTextBlobDeserialize(SkReadBuffer& buf) { #if defined(IS_FUZZING_WITH_LIBFUZZER) extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr; SkReadBuffer buf(data, size); FuzzTextBlobDeserialize(buf); return 0; |