[PATCH] D38855: Add a fuzz target for llvm's ItaniumDemangler.
Mitch Phillips via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 11:23:06 PDT 2017
hctim updated this revision to Diff 118814.
hctim added a comment.
- kcc's comments
https://reviews.llvm.org/D38855
Files:
tools/llvm-demangle-fuzzer/CMakeLists.txt
tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
Index: tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
===================================================================
--- /dev/null
+++ tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp
@@ -0,0 +1,24 @@
+//===--- llvm-demangle-fuzzer.cpp - Fuzzer for the Itanium Demangler ------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Demangle/Demangle.h"
+
+#include <cstdint>
+#include <cstdlib>
+#include <string>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ std::string NullTerminatedString((const char *)Data, Size);
+ int status = 0;
+ if (char *demangle = llvm::itaniumDemangle(NullTerminatedString.c_str(), nullptr,
+ nullptr, &status))
+ free(demangle);
+
+ return 0;
+}
Index: tools/llvm-demangle-fuzzer/CMakeLists.txt
===================================================================
--- /dev/null
+++ tools/llvm-demangle-fuzzer/CMakeLists.txt
@@ -0,0 +1,6 @@
+set(LLVM_LINK_COMPONENTS
+ Demangle
+)
+add_llvm_fuzzer(llvm-demangle-fuzzer
+ EXCLUDE_FROM_ALL
+ llvm-demangle-fuzzer.cpp)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38855.118814.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171012/7c9a1be4/attachment.bin>
More information about the llvm-commits
mailing list