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

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: Add test corpus Created 4 years, 4 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
« no previous file with comments | « third_party/sfntly/fuzzers/corpora/sfntly_fuzzer/test.ttc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 kMaxFontNameSize = 128;
12 constexpr int kMaxFontSize = 50 * 1024 * 1024;
13 base::FuzzedDataProvider fuzzed_data(data, size);
14
15 size_t font_name_size = fuzzed_data.ConsumeUint32InRange(0, kMaxFontNameSize);
16 base::StringPiece font_name = fuzzed_data.ConsumeBytes(font_name_size);
17
18 size_t font_str_size = fuzzed_data.ConsumeUint32InRange(0, kMaxFontSize);
19 base::StringPiece font_str = fuzzed_data.ConsumeBytes(font_str_size);
20 const unsigned char* font_data =
21 reinterpret_cast<const unsigned char*>(font_str.data());
22
23 base::StringPiece glyph_ids_str = fuzzed_data.ConsumeRemainingBytes();
24 const unsigned int* glyph_ids =
25 reinterpret_cast<const unsigned int*>(glyph_ids_str.data());
26 size_t glyph_ids_size =
27 glyph_ids_str.size() * sizeof(char) / sizeof(unsigned int);
28
29 unsigned char* output = nullptr;
30 SfntlyWrapper::SubsetFont(font_name.data(), font_data, font_str_size,
31 glyph_ids, glyph_ids_size, &output);
32 delete[] output;
33 return 0;
34 }
OLDNEW
« no previous file with comments | « third_party/sfntly/fuzzers/corpora/sfntly_fuzzer/test.ttc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698