Author: kcc Date: Tue Dec 27 21:28:29 2016 New Revision: 290650 URL: http://llvm.org/viewvc/llvm-project?rev=290650&view=rev Log: 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 Added: libcxxabi/trunk/fuzz/ libcxxabi/trunk/fuzz/CMakeLists.txt libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp Modified: libcxxabi/trunk/CMakeLists.txt Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=290650&r1=290649&r2=290650&view=diff ============================================================================== --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Tue Dec 27 21:28:29 2016 @@ -432,4 +432,5 @@ if (LIBCXXABI_STANDALONE_BUILD AND NOT L "available!") else() add_subdirectory(test) + add_subdirectory(fuzz) endif() Added: libcxxabi/trunk/fuzz/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/fuzz/CMakeLists.txt?rev=290650&view=auto ============================================================================== --- libcxxabi/trunk/fuzz/CMakeLists.txt (added) +++ libcxxabi/trunk/fuzz/CMakeLists.txt Tue Dec 27 21:28:29 2016 @@ -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() Added: libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp?rev=290650&view=auto ============================================================================== --- libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp (added) +++ libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp Tue Dec 27 21:28:29 2016 @@ -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; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits