zlib fuzzer

contributed by inferno@chromium.org
This commit is contained in:
Oliver Chang 2016-09-02 08:56:53 -07:00
parent a59d45e903
commit 9caeaaca37
4 changed files with 75 additions and 0 deletions

21
zlib/Dockerfile Normal file
View File

@ -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

23
zlib/Jenkinsfile vendored Normal file
View File

@ -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"
}

10
zlib/build.sh Executable file
View File

@ -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

View File

@ -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 <stddef.h>
#include <stdint.h>
#include <string.h>
#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<uLongf>(sizeof(buffer));
if (Z_OK != uncompress(buffer, &buffer_length, data,
static_cast<uLong>(size))) {
return 0;
}
return 0;
}