diff options
author | Kevin Lubick <kjlubick@google.com> | 2017-11-09 08:12:56 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-09 18:49:15 +0000 |
commit | c9d2829c5a82ebc34e2dac85088caadfa1df3126 (patch) | |
tree | df51797b6eeb5ae8a77ab003b3983bd246834daf /fuzz/fuzz.cpp | |
parent | fc45998242b6e95ff610fd2c4edcf72c10e536ab (diff) |
Use validating buffer for skpath
Bug: skia:
Change-Id: I92191e60c874ff123b7d839f5c65f32e180f69eb
Reviewed-on: https://skia-review.googlesource.com/69080
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'fuzz/fuzz.cpp')
-rw-r--r-- | fuzz/fuzz.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index d0f31506e9..c141686a1b 100644 --- a/fuzz/fuzz.cpp +++ b/fuzz/fuzz.cpp @@ -23,6 +23,7 @@ #include "SkRegion.h" #include "SkStream.h" #include "SkSurface.h" +#include "SkValidatingReadBuffer.h" #if SK_SUPPORT_GPU #include "SkSLCompiler.h" @@ -92,8 +93,6 @@ static int fuzz_file(const char* path) { return 1; } - uint8_t option = calculate_option(bytes.get()); - if (!FLAGS_type.isEmpty()) { if (0 == strcmp("api", FLAGS_type[0])) { fuzz_api(bytes); @@ -108,10 +107,12 @@ static int fuzz_file(const char* path) { return 0; } if (0 == strcmp("image_scale", FLAGS_type[0])) { + uint8_t option = calculate_option(bytes.get()); fuzz_img(bytes, option, 0); return 0; } if (0 == strcmp("image_mode", FLAGS_type[0])) { + uint8_t option = calculate_option(bytes.get()); fuzz_img(bytes, 0, option); return 0; } @@ -472,10 +473,13 @@ static void fuzz_color_deserialize(sk_sp<SkData> bytes) { static void fuzz_path_deserialize(sk_sp<SkData> bytes) { SkPath path; - if (!path.readFromMemory(bytes->data(), bytes->size())) { - SkDebugf("[terminated] Couldn't initialize SkPath.\n"); + SkValidatingReadBuffer buf(bytes->data(), bytes->size()); + buf.readPath(&path); + if (!buf.isValid()) { + SkDebugf("[terminated] Couldn't deserialize SkPath.\n"); return; } + auto s = SkSurface::MakeRasterN32Premul(1024, 1024); s->getCanvas()->drawPath(path, SkPaint()); SkDebugf("[terminated] Success! Initialized SkPath.\n"); |