diff options
author | Fabian Meumertzheim <meumertzheim@code-intelligence.com> | 2021-03-12 11:25:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-12 11:25:14 +0100 |
commit | ea1214019cae2e4f63c38e1fb1e35ba31d12928d (patch) | |
tree | 31ff525ebce0c0801e60c55c241b4c23c4828c87 /examples | |
parent | 00f81b5cb6d53e5e6e3b88c49f1bcc9502a83cb3 (diff) | |
download | jazzer-api-ea1214019cae2e4f63c38e1fb1e35ba31d12928d.tar.gz |
Annotate OutOfMemoryError and StackOverflowError with severity (#39)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/BUILD.bazel | 9 | ||||
-rw-r--r-- | examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java | 28 |
2 files changed, 37 insertions, 0 deletions
diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 66a85855..9b5951a0 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -36,6 +36,15 @@ java_fuzz_target_test( ) java_fuzz_target_test( + name = "ExampleOutOfMemoryFuzzer", + srcs = [ + "src/main/java/com/example/ExampleOutOfMemoryFuzzer.java", + ], + fuzzer_args = ["--jvm_args=-Xmx512m"], + target_class = "com.example.ExampleOutOfMemoryFuzzer", +) + +java_fuzz_target_test( name = "JpegImageParserFuzzer", srcs = [ "src/main/java/com/example/JpegImageParserFuzzer.java", diff --git a/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java b/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java new file mode 100644 index 00000000..d704da39 --- /dev/null +++ b/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java @@ -0,0 +1,28 @@ +// Copyright 2021 Code Intelligence GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.example; + +import java.util.ArrayList; + +public class ExampleOutOfMemoryFuzzer { + public static void fuzzerTestOneInput(byte[] input) { + ArrayList<Byte> bytes = new ArrayList<>(); + int pos = 0; + while (pos >= 0 && pos < input.length) { + bytes.add(input[pos]); + pos += input[pos] + 1; + } + } +} |