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

Side by Side Diff: testing/libfuzzer/fuzzers/template_url_parser_fuzzer.cc

Issue 2123733002: Add a fuzzer for TemplateURLParser/Open Search Descriptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try to fix Linux build problem. Created 3 years, 9 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 | « testing/libfuzzer/fuzzers/BUILD.gn ('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 Chromium 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 <stddef.h>
6 #include <stdint.h>
7
8 #include <random>
9 #include <string>
10
11 #include "components/search_engines/search_terms_data.h"
12 #include "components/search_engines/template_url.h"
13 #include "components/search_engines/template_url_parser.h"
14
15 class PseudoRandomFilter : public TemplateURLParser::ParameterFilter {
16 public:
17 PseudoRandomFilter(uint32_t seed) : generator_(seed), pool_(0, 1) {}
18 ~PseudoRandomFilter() override = default;
19
20 bool KeepParameter(const std::string&, const std::string&) override {
21 return pool_(generator_);
22 }
23
24 private:
25 std::mt19937 generator_;
26 std::uniform_int_distribution<uint8_t> pool_;
27 };
28
29 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
30 const char* char_data = reinterpret_cast<const char*>(data);
31 std::size_t data_hash =
aizatsky 2017/03/20 20:14:04 with this approach every input bit change would re
32 std::hash<std::string>()(std::string(char_data, size));
33 PseudoRandomFilter filter(static_cast<uint32_t>(data_hash));
34 TemplateURLParser::Parse(SearchTermsData(), char_data, size, &filter);
35 return 0;
36 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/fuzzers/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698