diff --git a/projects/brotli-java/Dockerfile b/projects/brotli-java/Dockerfile new file mode 100644 index 000000000..a8adcd0d0 --- /dev/null +++ b/projects/brotli-java/Dockerfile @@ -0,0 +1,27 @@ +# Copyright 2021 Google LLC +# +# 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. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder-jvm +RUN apt-get update && apt-get install -y make autoconf automake libtool wget +RUN curl -L https://downloads.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip -o maven.zip && \ + unzip maven.zip -d $SRC/maven && \ + rm -rf maven.zip +ENV MVN $SRC/maven/apache-maven-3.8.3/bin/mvn + +RUN git clone --depth 1 https://github.com/google/brotli brotli-java +WORKDIR brotli-java +COPY build.sh $SRC/ +COPY *.java $SRC/ diff --git a/projects/brotli-java/FuzzDecode.java b/projects/brotli-java/FuzzDecode.java new file mode 100644 index 000000000..ffd82cf10 --- /dev/null +++ b/projects/brotli-java/FuzzDecode.java @@ -0,0 +1,36 @@ +// Copyright 2021 Google LLC +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +import com.code_intelligence.jazzer.api.FuzzedDataProvider; + +import java.io.*; +import org.brotli.dec.BrotliInputStream; + +public class FuzzDecode { + public static void fuzzerTestOneInput(FuzzedDataProvider data) { + byte[] buffer = new byte[65536]; + ByteArrayInputStream input = new ByteArrayInputStream(data.consumeBytes(65536)); + try { + BrotliInputStream brotliInput = new BrotliInputStream(input); + while (true) { + int len = brotliInput.read(buffer, 0, buffer.length); + if (len <= 0) { + break; + } + } + } catch (IOException expected) {} + } +} diff --git a/projects/brotli-java/build.sh b/projects/brotli-java/build.sh new file mode 100755 index 000000000..0a9f5bf26 --- /dev/null +++ b/projects/brotli-java/build.sh @@ -0,0 +1,45 @@ +#!/bin/bash -eu +# Copyright 2021 Google LLC +# +# 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. +# +################################################################################ + +cd java/org/brotli +sed -i 's/1.6 $OUT/$fuzzer_basename + chmod u+x $OUT/$fuzzer_basename +done diff --git a/projects/brotli-java/project.yaml b/projects/brotli-java/project.yaml new file mode 100644 index 000000000..afbf7de9a --- /dev/null +++ b/projects/brotli-java/project.yaml @@ -0,0 +1,10 @@ +homepage: "https://github.com/google/brotli/tree/master/java" +language: jvm +primary_contact: "eustas@chromium.org" +main_repo: "https://github.com/google/brotli" +auto_ccs: + - "david@adalogics.com" +fuzzing_engines: + - libfuzzer +sanitizers: + - address