llvm.org GIT mirror llvm / b1b02b7
[llvm-demangle-fuzzer] Add a fuzz target for ItaniumDemangler. Patch By: hctim Reviewers: morehouse, bogner Reviewed By: bogner Subscribers: bogner, kcc, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D38855 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315716 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Morehouse 1 year, 10 months ago
4 changed file(s) with 58 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6666 this fuzzer has reported are `on OSS Fuzz's tracker`__
6767
6868 __ https://bugs.chromium.org/p/oss-fuzz/issues/list?q=proj-llvm+llvm-dwarfdump-fuzzer
69
70 llvm-demangle-fuzzer
71 ---------------------
72
73 A |generic fuzzer| for the Itanium demangler used in various LLVM tools. We've
74 fuzzed __cxa_demangle to death, why not fuzz LLVM's implementation of the same
75 function!
6976
7077 llvm-isel-fuzzer
7178 ----------------
0 set(LLVM_LINK_COMPONENTS
1 Demangle
2 FuzzMutate
3 )
4
5 add_llvm_fuzzer(llvm-demangle-fuzzer
6 llvm-demangle-fuzzer.cpp
7 DUMMY_MAIN DummyDemanglerFuzzer.cpp)
0 //===--- DummyDemanglerMain.cpp - Entry point to sanity check the fuzzer --===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implementation of main so we can build and test without linking libFuzzer.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/FuzzMutate/FuzzerCLI.h"
14
15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
16 int main(int argc, char *argv[]) {
17 return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput);
18 }
0 //===--- llvm-demangle-fuzzer.cpp - Fuzzer for the Itanium Demangler ------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/Demangle/Demangle.h"
10
11 #include
12 #include
13 #include
14
15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
16 std::string NullTerminatedString((const char *)Data, Size);
17 int status = 0;
18 if (char *demangle = llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr,
19 nullptr, &status))
20 free(demangle);
21
22 return 0;
23 }