From da4c3b95347573d67893f872b4e9967c90ee4a3e Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 1 Jun 2021 13:30:47 +0200 Subject: Add additional_jvm_args flag In certain situations, such as OSS-Fuzz coverage reports, additional JVM args need to be specified on the command line after --jvm_args has already been used. Specifying --jvm_args again overrides the previous arguments rather than appending to them. This commit adds an additional flag for adding JVM args that will be emitted after the flags specified in --jvm_args. --- examples/BUILD.bazel | 1 + examples/src/main/java/com/example/JpegImageParserFuzzer.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index df1e7832..b2d021d0 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -75,6 +75,7 @@ java_fuzz_target_test( # processes. Quoting with both " and ' is necessary in this test since # one level of quoting is lost when passing through jazzer_wrapper.sh "--jvm_args=\"'-Dfoo=foo;-Dbar=bar'\"", + "--additional_jvm_args=\"'-Dbaz=baz'\"", ], # The exit codes of the forked libFuzzer processes are not picked up correctly. tags = ["broken-on-darwin"], diff --git a/examples/src/main/java/com/example/JpegImageParserFuzzer.java b/examples/src/main/java/com/example/JpegImageParserFuzzer.java index 6a36f8f1..84a1029a 100644 --- a/examples/src/main/java/com/example/JpegImageParserFuzzer.java +++ b/examples/src/main/java/com/example/JpegImageParserFuzzer.java @@ -24,7 +24,8 @@ import org.apache.commons.imaging.formats.jpeg.JpegImageParser; public class JpegImageParserFuzzer { public static void fuzzerInitialize() { // Only used to verify that arguments are correctly passed down to child processes. - if (System.getProperty("foo") == null || System.getProperty("bar") == null) { + if (System.getProperty("foo") == null || System.getProperty("bar") == null + || System.getProperty("baz") == null) { // Exit the process with an exit code different from that for a finding. System.err.println("ERROR: Did not pass all jvm_args to child process."); System.exit(3); -- cgit v1.2.3