From c9d2829c5a82ebc34e2dac85088caadfa1df3126 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Thu, 9 Nov 2017 08:12:56 -0500 Subject: Use validating buffer for skpath Bug: skia: Change-Id: I92191e60c874ff123b7d839f5c65f32e180f69eb Reviewed-on: https://skia-review.googlesource.com/69080 Reviewed-by: Kevin Lubick Commit-Queue: Kevin Lubick --- fuzz/fuzz.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'fuzz/fuzz.cpp') 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 bytes) { static void fuzz_path_deserialize(sk_sp 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"); -- cgit v1.2.3