@@ -0,0 +1,2800 @@
+// Copyright 2022 Google LLC%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//      http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0A////////////////////////////////////////////////////////////////////////////////%0A%0Aimport com.code_intelligence.jazzer.api.FuzzedDataProvider;%0A%0Aimport com.fasterxml.jackson.core.json.*;%0Aimport com.fasterxml.jackson.core.io.ContentReference;%0Aimport com.fasterxml.jackson.core.io.IOContext;%0Aimport com.fasterxml.jackson.core.util.BufferRecycler;%0Aimport com.fasterxml.jackson.core.JsonGenerator;%0Aimport com.fasterxml.jackson.core.JsonFactory;%0A%0Aimport java.io.IOException;%0Aimport java.io.*;%0Aimport com.fasterxml.jackson.core.io.SerializedString;%0Aimport com.fasterxml.jackson.core.SerializableString;%0A%0Apublic class WriterBasedJsonGeneratorFuzzer %7B%0A  private IOContext getIOContext() %7B%0A    return new IOContext(new BufferRecycler(), ContentReference.unknown(), false);%0A  %7D%0A  public static void fuzzerTestOneInput(FuzzedDataProvider data) %7B%0A    JsonFactory jf = new JsonFactory();%0A    StringWriter w;%0A    JsonGenerator jg;%0A%0A    try %7B%0A      w = new StringWriter();%0A      jg = jf.createGenerator(w);%0A    %7D catch (IOException e) %7B%0A      return;%0A    %7D%0A%0A    try %7B%0A      int numberOfOps = data.consumeInt();%0A      for (int i=0;i%3CnumberOfOps%2520;i++) %7B%0A        int opType = data.consumeInt();%0A        switch (opType%255) %7B%0A        case 0:%0A          jg.writeStartObject();%0A          jg.writeFieldName(data.consumeString(100000));%0A          jg.writeString(data.consumeString(100000));%0A          jg.writeEndObject();%0A        case 1:%0A          jg.writeStartObject();%0A          jg.writeStringField(data.consumeString(100000), data.consumeString(100000));%0A          jg.writeEndObject();%0A        case 2:%0A          jg.writeStartObject();%0A          SerializableString NAME = new SerializedString(data.consumeString(100000));%0A          jg.writeFieldName(NAME);%0A          jg.writeString(data.consumeString(100000));%0A          jg.writeEndObject();%0A        case 3:%0A          jg.writeStartArray();%0A          jg.writeRaw(data.consumeString(100000));%0A          jg.writeEndArray();%0A        case 4:%0A          jg.writeStartArray();%0A          jg.writeRawValue(data.consumeString(100000));%0A          jg.writeEndArray();%0A        %7D%0A      %7D      %0A    %7D catch (IOException e) %7B %7D%0A%0A    try %7B%0A      jg.close();%0A    %7D catch (IOException e) %7B %7D%0A    %0A  %7D%0A%7D%0A

add fuzzer (#8208)