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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sfntly/fuzzers/subset_font_fuzzer.cc
diff --git a/third_party/sfntly/fuzzers/subset_font_fuzzer.cc b/third_party/sfntly/fuzzers/subset_font_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..08383e19c8420d030e6f2342884ccf470de725fa
--- /dev/null
+++ b/third_party/sfntly/fuzzers/subset_font_fuzzer.cc
@@ -0,0 +1,34 @@
+// Copyright 2016 The Chromimum Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdint>
+
+#include "base/test/fuzzed_data_provider.h"
+#include "third_party/sfntly/src/cpp/src/sample/chromium/font_subsetter.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ constexpr int kMaxFontNameSize = 128;
+ constexpr int kMaxFontSize = 50 * 1024 * 1024;
+ base::FuzzedDataProvider fuzzed_data(data, size);
+
+ size_t font_name_size = fuzzed_data.ConsumeUint32InRange(0, kMaxFontNameSize);
+ base::StringPiece font_name = fuzzed_data.ConsumeBytes(font_name_size);
+
+ size_t font_str_size = fuzzed_data.ConsumeUint32InRange(0, kMaxFontSize);
+ base::StringPiece font_str = fuzzed_data.ConsumeBytes(font_str_size);
+ const unsigned char* font_data =
+ reinterpret_cast<const unsigned char*>(font_str.data());
+
+ base::StringPiece glyph_ids_str = fuzzed_data.ConsumeRemainingBytes();
+ const unsigned int* glyph_ids =
+ reinterpret_cast<const unsigned int*>(glyph_ids_str.data());
+ size_t glyph_ids_size =
+ glyph_ids_str.size() * sizeof(char) / sizeof(unsigned int);
+
+ unsigned char* output = nullptr;
+ SfntlyWrapper::SubsetFont(font_name.data(), font_data, font_str_size,
+ glyph_ids, glyph_ids_size, &output);
+ delete[] output;
+ return 0;
+}
« 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