Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |