fuzz_target.cc
Go to the documentation of this file.
1 // Copyright 2016 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "bloaty.h"
16 #include "bloaty.pb.h"
17 #include "strarr.h"
18 
19 #include "absl/strings/string_view.h"
20 
21 using absl::string_view;
22 
23 namespace bloaty {
24 
26  public:
28  : InputFile("fake_StringPieceInputFile_file") {
29  data_ = data;
30  }
31 };
32 
34  public:
36  private:
38  std::unique_ptr<InputFile> OpenFile(
39  const std::string& /* filename */) const override {
40  return std::unique_ptr<InputFile>(new StringPieceInputFile(data_));
41  }
42 };
43 
44 void RunBloaty(const InputFileFactory& factory,
45  const std::string& data_source) {
47  bloaty::Options options;
49  options.add_data_source(data_source);
50  options.add_filename("dummy_filename");
51  bloaty::BloatyMain(options, factory, &output, &error);
52 }
53 
54 } // namespace bloaty
55 
56 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
57  const char *data2 = reinterpret_cast<const char*>(data);
59 
60  // Try all of the data sources.
61  RunBloaty(factory, "segments");
62  RunBloaty(factory, "sections");
63  RunBloaty(factory, "symbols");
64  RunBloaty(factory, "compileunits");
65  RunBloaty(factory, "inlines");
66  RunBloaty(factory, "armembers");
67 
68  return 0;
69 }
bloaty
Definition: bloaty.cc:69
bloaty::RunBloaty
void RunBloaty(const InputFileFactory &factory, const std::string &data_source)
Definition: fuzz_target.cc:44
options
double_dict options[]
Definition: capstone_test.c:55
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
bloaty.h
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
bloaty::BloatyMain
bool BloatyMain(const Options &options, const InputFileFactory &file_factory, RollupOutput *output, std::string *error)
Definition: bloaty.cc:2196
bloaty::RollupOutput
Definition: bloaty.h:376
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
bloaty::StringPieceInputFile
Definition: fuzz_target.cc:25
bloaty::StringPieceInputFileFactory::OpenFile
std::unique_ptr< InputFile > OpenFile(const std::string &) const override
Definition: fuzz_target.cc:38
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Definition: fuzz_target.cc:56
strarr.h
bloaty::InputFile::data_
absl::string_view data_
Definition: bloaty.h:84
bloaty::StringPieceInputFileFactory::data_
string_view data_
Definition: fuzz_target.cc:37
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
string_view
absl::string_view string_view
Definition: attr.cc:22
bloaty::StringPieceInputFile::StringPieceInputFile
StringPieceInputFile(string_view data)
Definition: fuzz_target.cc:27
bloaty::StringPieceInputFileFactory
Definition: fuzz_target.cc:33
bloaty::InputFile::data
absl::string_view data() const
Definition: bloaty.h:78
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
bloaty::StringPieceInputFileFactory::StringPieceInputFileFactory
StringPieceInputFileFactory(string_view data)
Definition: fuzz_target.cc:35
bloaty::InputFile
Definition: bloaty.h:70
bloaty::InputFileFactory
Definition: bloaty.h:87


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:23