Skip to content

Commit 4eb60cb

Browse files
committedDec 28, 2016
add cxa_demangle_fuzzer
Summary: All easy-to-find bugs in cxa_demangle where fixed now (https://bugs.chromium.org/p/chromium/issues/detail?id=606626) except for one (https://llvm.org/bugs/show_bug.cgi?id=31031). Now I'd like to properly integrate this fuzzer with the source tree and then run the fuzzer continuously on https://github.com/google/oss-fuzz Reviewers: compnerd, mclow.lists, mehdi_amini Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D28133 llvm-svn: 290650
1 parent 9900d18 commit 4eb60cb

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
 

‎libcxxabi/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,5 @@ if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED)
432432
"available!")
433433
else()
434434
add_subdirectory(test)
435+
add_subdirectory(fuzz)
435436
endif()

‎libcxxabi/fuzz/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# See http://llvm.org/docs/LibFuzzer.html
2+
if( LLVM_USE_SANITIZE_COVERAGE )
3+
add_executable(cxa_demangle_fuzzer
4+
cxa_demangle_fuzzer.cpp
5+
../src/cxa_demangle.cpp
6+
)
7+
8+
target_link_libraries(cxa_demangle_fuzzer
9+
LLVMFuzzer
10+
)
11+
endif()
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdint.h>
2+
#include <stddef.h>
3+
#include <string.h>
4+
#include <stdlib.h>
5+
extern "C" char *
6+
__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
7+
8+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
9+
char *str = new char[size+1];
10+
memcpy(str, data, size);
11+
str[size] = 0;
12+
free(__cxa_demangle(str, 0, 0, 0));
13+
delete [] str;
14+
return 0;
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.