Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: third_party/sfntly/fuzzers/subset_font_fuzzer.cc

Issue 2268863003: Add a fuzzer for SfntlyWrapper::SubsetFont(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix undefined shift in FuzzedDataProvider Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromimum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <cstdint>
6
7 #include "base/test/fuzzed_data_provider.h"
8 #include "third_party/sfntly/src/cpp/src/sample/chromium/font_subsetter.h"
9
10 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
11 constexpr int kMaxFontSize = 50 * 1024 * 1024;
12 base::FuzzedDataProvider fuzzed_data(data, size);
13 size_t font_size = fuzzed_data.ConsumeUint32InRange(0, kMaxFontSize);
14 base::StringPiece font_str = fuzzed_data.ConsumeBytes(font_size);
15 base::StringPiece glyph_ids_str = fuzzed_data.ConsumeRemainingBytes();
16 const unsigned int* glyph_ids =
17 reinterpret_cast<const unsigned int*>(glyph_ids_str.data());
18 const unsigned char* font_data =
19 reinterpret_cast<const unsigned char*>(font_str.data());
20 size_t glyph_ids_size =
21 glyph_ids_str.size() * sizeof(char) / sizeof(unsigned int);
22
23 unsigned char* output = nullptr;
24 SfntlyWrapper::SubsetFont(nullptr, font_data, font_size, glyph_ids,
hal.canary 2016/08/23 15:48:23 constexpr int kMaxFontNameSize = 128; size_t
Lei Zhang 2016/08/23 18:05:50 Done.
25 glyph_ids_size, &output);
26 delete[] output;
27 return 0;
28 }
OLDNEW
« base/test/fuzzed_data_provider.cc ('K') | « third_party/sfntly/fuzzers/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698