diff options
Diffstat (limited to 'projects/java-example/ExampleFuzzerNative.cpp')
-rw-r--r-- | projects/java-example/ExampleFuzzerNative.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/projects/java-example/ExampleFuzzerNative.cpp b/projects/java-example/ExampleFuzzerNative.cpp index 0e37aee5d..565f75cf9 100644 --- a/projects/java-example/ExampleFuzzerNative.cpp +++ b/projects/java-example/ExampleFuzzerNative.cpp @@ -16,15 +16,21 @@ #include "ExampleFuzzerNative.h" +#include <limits> #include <string> // simple function containing a crash that requires coverage and string compare // instrumentation for the fuzzer to find -void parseInternal(const std::string &input) { +__attribute__((optnone)) void parseInternal(const std::string &input) { + constexpr int bar = std::numeric_limits<int>::max() - 5; + // Crashes with UBSan. + if (bar + input[0] == 300) { + return; + } if (input[0] == 'a' && input[1] == 'b' && input[5] == 'c') { if (input.find("secret_in_native_library") != std::string::npos) { - // BOOM - *(char *)0xFF = 2; + // Crashes with ASan. + [[maybe_unused]] char foo = input[input.size() + 2]; } } } |