diff --git a/zlib/Dockerfile b/zlib/Dockerfile new file mode 100644 index 000000000..68da3e75d --- /dev/null +++ b/zlib/Dockerfile @@ -0,0 +1,21 @@ +# Copyright 2016 Google Inc. +# +# 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 ossfuzz/base-libfuzzer +MAINTAINER inferno@chromium.org +RUN apt-get install -y make autoconf automake libtool + +CMD /src/oss-fuzz/zlib/build.sh diff --git a/zlib/Jenkinsfile b/zlib/Jenkinsfile new file mode 100644 index 000000000..ce481f35b --- /dev/null +++ b/zlib/Jenkinsfile @@ -0,0 +1,23 @@ +// Copyright 2016 Google Inc. +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +def libfuzzerBuild = fileLoader.fromGit('infra/libfuzzer-pipeline.groovy', + 'https://github.com/google/oss-fuzz.git', + 'master', null, '') + +libfuzzerBuild { + git = "https://github.com/madler/zlib.git" +} diff --git a/zlib/build.sh b/zlib/build.sh new file mode 100755 index 000000000..c7013a2dd --- /dev/null +++ b/zlib/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +cd /src/zlib + +./configure +make clean all + +$CXX $CXXFLAGS -std=c++11 -I. \ + /src/oss-fuzz/zlib/zlib_uncompress_fuzzer.cc -o /out/zlib_uncompress_fuzzer \ + /work/libfuzzer/*.o ./libz.a $LDFLAGS diff --git a/zlib/zlib_uncompress_fuzzer.cc b/zlib/zlib_uncompress_fuzzer.cc new file mode 100644 index 000000000..808793b86 --- /dev/null +++ b/zlib/zlib_uncompress_fuzzer.cc @@ -0,0 +1,21 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include + +#include "zlib.h" + +static Bytef buffer[256 * 1024] = { 0 }; + +// Entry point for LibFuzzer. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + uLongf buffer_length = static_cast(sizeof(buffer)); + if (Z_OK != uncompress(buffer, &buffer_length, data, + static_cast(size))) { + return 0; + } + return 0; +}