[PATCH] D28133: add cxa_demangle_fuzzer
Kostya Serebryany via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 27 18:57:59 PST 2016
kcc updated this revision to Diff 82571.
kcc added a comment.
remove unneeded set(LLVM_LINK_COMPONENTS support)
https://reviews.llvm.org/D28133
Files:
CMakeLists.txt
fuzz/
fuzz/CMakeLists.txt
fuzz/cxa_demangle_fuzzer.cpp
Index: fuzz/cxa_demangle_fuzzer.cpp
===================================================================
--- /dev/null
+++ fuzz/cxa_demangle_fuzzer.cpp
@@ -0,0 +1,15 @@
+#include <stdint.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+extern "C" char *
+__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char *str = new char[size+1];
+ memcpy(str, data, size);
+ str[size] = 0;
+ free(__cxa_demangle(str, 0, 0, 0));
+ delete [] str;
+ return 0;
+}
Index: fuzz/CMakeLists.txt
===================================================================
--- /dev/null
+++ fuzz/CMakeLists.txt
@@ -0,0 +1,11 @@
+# See http://llvm.org/docs/LibFuzzer.html
+if( LLVM_USE_SANITIZE_COVERAGE )
+ add_executable(cxa_demangle_fuzzer
+ cxa_demangle_fuzzer.cpp
+ ../src/cxa_demangle.cpp
+ )
+
+ target_link_libraries(cxa_demangle_fuzzer
+ LLVMFuzzer
+ )
+endif()
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -432,4 +432,5 @@
"available!")
else()
add_subdirectory(test)
+ add_subdirectory(fuzz)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28133.82571.patch
Type: text/x-patch
Size: 1237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161228/a14fd5a9/attachment.bin>
More information about the cfe-commits
mailing list