Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "base/at_exit.h" | |
| 6 #include "base/i18n/icu_util.h" | |
| 7 #include "base/strings/string_piece.h" | |
| 8 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | |
| 9 #include "url/gurl.h" | |
| 10 | |
| 11 // Initialize ICU. | |
| 12 struct InitICU { | |
| 13 InitICU() { CHECK(base::i18n::InitializeICU()); } | |
| 14 base::AtExitManager at_exit_manager; | |
| 15 }; | |
| 16 | |
| 17 InitICU* init_icu = new InitICU(); | |
| 18 | |
| 19 // Entry point for LibFuzzer. | |
| 20 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
| 21 net::registry_controlled_domains::PrivateRegistryFilter filter = | |
| 22 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES; | |
| 23 | |
| 24 // Consume the first byte to determine which filter mode to use. | |
| 25 if (size > 0) { | |
| 26 uint8_t first_byte = *data; | |
| 27 size--; | |
|
mmoroz
2016/02/26 09:18:45
Since we use first byte of |data| and decrease |si
eroman
2016/02/26 20:37:19
Oops yes, that was my intent :)
| |
| 28 if ((first_byte % 2) == 1) | |
| 29 filter = net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES; | |
| 30 } | |
| 31 | |
| 32 std::string input(data, data + size); | |
|
mmoroz
2016/02/26 09:18:45
Unused variable |input|?
eroman
2016/02/26 20:37:19
Fixed.
| |
| 33 | |
| 34 net::registry_controlled_domains::GetDomainAndRegistry( | |
| 35 base::StringPiece(reinterpret_cast<const char*>(data), size), filter); | |
| 36 | |
| 37 return 0; | |
| 38 } | |
| OLD | NEW |