OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <random> | 8 #include <random> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 private: | 26 private: |
27 std::mt19937 generator_; | 27 std::mt19937 generator_; |
28 std::uniform_int_distribution<uint8_t> pool_; | 28 std::uniform_int_distribution<uint8_t> pool_; |
29 }; | 29 }; |
30 | 30 |
31 struct FuzzerFixedParams { | 31 struct FuzzerFixedParams { |
32 uint32_t seed_; | 32 uint32_t seed_; |
33 }; | 33 }; |
34 | 34 |
| 35 base::AtExitManager at_exit_manager; // used by ICU integration |
| 36 |
| 37 extern "C" int LLVMFuzzerInitialize(int argc, char*** argv) { |
| 38 CHECK(base::i18n::InitializeICU()); |
| 39 return 0; |
| 40 } |
| 41 |
35 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 42 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
36 if (size < sizeof(FuzzerFixedParams)) { | 43 if (size < sizeof(FuzzerFixedParams)) { |
37 return 0; | 44 return 0; |
38 } | 45 } |
39 base::AtExitManager at_exit_manager; // used by ICU integration. | |
40 base::i18n::InitializeICU(); | |
41 const FuzzerFixedParams* params = | 46 const FuzzerFixedParams* params = |
42 reinterpret_cast<const FuzzerFixedParams*>(data); | 47 reinterpret_cast<const FuzzerFixedParams*>(data); |
43 size -= sizeof(FuzzerFixedParams); | 48 size -= sizeof(FuzzerFixedParams); |
44 const char* char_data = reinterpret_cast<const char*>(params + 1); | 49 const char* char_data = reinterpret_cast<const char*>(params + 1); |
45 PseudoRandomFilter filter(params->seed_); | 50 PseudoRandomFilter filter(params->seed_); |
46 TemplateURLParser::Parse(SearchTermsData(), char_data, size, &filter); | 51 TemplateURLParser::Parse(SearchTermsData(), char_data, size, &filter); |
47 return 0; | 52 return 0; |
48 } | 53 } |
OLD | NEW |