• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 Code Intelligence GmbH
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.example;
16 
17 import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow;
18 
19 public final class ForkModeFuzzer {
fuzzerInitialize()20   public static void fuzzerInitialize() {
21     // When running through a Java reproducer, do not check the Java opts.
22     if (System.getProperty("jazzer.is_reproducer") != null)
23       return;
24     String foo = System.getProperty("foo");
25     String bar = System.getProperty("bar");
26     String baz = System.getProperty("baz");
27     // Only used to verify that arguments are correctly passed down to child processes.
28     if (foo == null || bar == null || baz == null || !foo.equals("foo")
29         || !(bar.equals("b;ar") || bar.equals("b:ar")) || !baz.equals("baz")) {
30       // Exit the process with an exit code different from that for a finding.
31       System.err.println("ERROR: Did not correctly pass all jvm_args to child process.");
32       System.err.printf("foo: %s%nbar: %s%nbaz: %s%n", foo, bar, baz);
33       System.exit(3);
34     }
35     // Only used to verify that Jazzer honors the JAVA_OPTS env var.
36     String javaOpts = System.getProperty("java_opts");
37     if (javaOpts == null || !javaOpts.equals("1")) {
38       // Exit the process with an exit code different from that for a finding.
39       System.err.println("ERROR: Did not honor JAVA_OPTS.");
40       System.err.printf("java_opts: %s%n", javaOpts);
41       System.exit(4);
42     }
43   }
44 
fuzzerTestOneInput(byte[] data)45   public static void fuzzerTestOneInput(byte[] data) {
46     throw new FuzzerSecurityIssueLow("Passed fuzzerInitialize");
47   }
48 }
49