1 // Copyright 2018 The Fuchsia 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 7 #include <fbl/auto_call.h> 8 #include <hid-parser/parser.h> 9 10 // fuzz_target.cc LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)11extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 12 hid::DeviceDescriptor* dd = nullptr; 13 auto result = hid::ParseReportDescriptor(data, size, &dd); 14 if (result != hid::ParseResult::kParseOk) { 15 return 0; 16 } 17 auto cleanup = fbl::MakeAutoCall([dd]() { hid::FreeDeviceDescriptor(dd); }); 18 19 size_t ff_count = 0u; 20 auto collection __attribute__((unused)) = 21 hid::GetAppCollection(hid::GetFirstInputField(dd, &ff_count)); 22 return 0; 23 } 24