llvm.org GIT mirror llvm / b37be36
[llvm-demangle-fuzzer] Also fuzz microsoftDemangle(). Summary: Use first byte of input to determine whether to call itaniumDemangle() or microsoftDemangle(). Addresses https://bugs.llvm.org/show_bug.cgi?id=39582. Reviewers: kcc, thakis Reviewed By: kcc, thakis Subscribers: mgorny, thakis, erik.pilkington, llvm-commits Differential Revision: https://reviews.llvm.org/D54780 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350534 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Morehouse 1 year, 10 months ago
9 changed file(s) with 103 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
+0
-10
tools/llvm-demangle-fuzzer/CMakeLists.txt less more
None set(LLVM_LINK_COMPONENTS
1 Demangle
2 FuzzMutate
3 Support
4 )
5
6 add_llvm_fuzzer(llvm-demangle-fuzzer
7 llvm-demangle-fuzzer.cpp
8 DUMMY_MAIN DummyDemanglerFuzzer.cpp
9 )
+0
-19
tools/llvm-demangle-fuzzer/DummyDemanglerFuzzer.cpp less more
None //===--- 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
-24
tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp less more
None //===--- 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 }
0 set(LLVM_LINK_COMPONENTS
1 Demangle
2 FuzzMutate
3 Support
4 )
5
6 add_llvm_fuzzer(llvm-itanium-demangle-fuzzer
7 llvm-itanium-demangle-fuzzer.cpp
8 DUMMY_MAIN DummyDemanglerFuzzer.cpp
9 )
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 }
0 set(LLVM_LINK_COMPONENTS
1 Demangle
2 FuzzMutate
3 Support
4 )
5
6 add_llvm_fuzzer(llvm-microsoft-demangle-fuzzer
7 llvm-microsoft-demangle-fuzzer.cpp
8 DUMMY_MAIN DummyDemanglerFuzzer.cpp
9 )
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 free(llvm::microsoftDemangle(NullTerminatedString.c_str(), nullptr, nullptr,
18 nullptr));
19 return 0;
20 }