[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 10:47:20 PDT 2017
hctim created this revision.
Herald added a subscriber: mgorny.
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>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ int status = 0;
+ char *demangle =
+ llvm::itaniumDemangle((const char *)Data, nullptr, nullptr, &status);
+
+ if (demangle)
+ 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.118808.patch
Type: text/x-patch
Size: 1216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171012/472beea0/attachment.bin>
More information about the llvm-commits
mailing list