1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifdef UNSAFE_BUFFERS_BUILD 6 // TODO(crbug.com/40284755): Remove this and spanify to fix the errors. 7 #pragma allow_unsafe_buffers 8 #endif 9 10 #include <stddef.h> 11 #include <stdint.h> 12 13 #include <string> 14 #include <vector> 15 16 #include "base/test/bind.h" 17 #include "net/dns/nsswitch_reader.h" 18 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)19extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 20 std::string input(reinterpret_cast<const char*>(data), size); 21 net::NsswitchReader::FileReadCall file_read_call = 22 base::BindLambdaForTesting([input]() { return input; }); 23 24 net::NsswitchReader reader; 25 reader.set_file_read_call_for_testing(std::move(file_read_call)); 26 27 std::vector<net::NsswitchReader::ServiceSpecification> result = 28 reader.ReadAndParseHosts(); 29 30 return 0; 31 } 32