From 351bf4c3c8d50ed1bf92a1756c8178834b75477a Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Mon, 22 Jun 2020 11:32:53 -0700 Subject: [PATCH] Updated c-blosc to use fuzzers in c-blosc repository. (#4018) Use compat files for seed corpus with new decompress_fuzzer. --- projects/c-blosc/Dockerfile | 2 +- projects/c-blosc/blosc_fuzzer.cc | 33 -------------------------------- projects/c-blosc/build.sh | 22 ++++++++++----------- projects/c-blosc/project.yaml | 3 +++ 4 files changed, 14 insertions(+), 46 deletions(-) delete mode 100644 projects/c-blosc/blosc_fuzzer.cc diff --git a/projects/c-blosc/Dockerfile b/projects/c-blosc/Dockerfile index aed3ecae5..896791b39 100644 --- a/projects/c-blosc/Dockerfile +++ b/projects/c-blosc/Dockerfile @@ -19,4 +19,4 @@ MAINTAINER blosc.oss.fuzz@gmail.com RUN apt-get update && apt-get install -y make autoconf automake libtool cmake RUN git clone --depth 1 https://github.com/Blosc/c-blosc.git c-blosc WORKDIR c-blosc -COPY build.sh blosc_fuzzer.cc $SRC/ +COPY build.sh $SRC/ \ No newline at end of file diff --git a/projects/c-blosc/blosc_fuzzer.cc b/projects/c-blosc/blosc_fuzzer.cc deleted file mode 100644 index c769c38fd..000000000 --- a/projects/c-blosc/blosc_fuzzer.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2019 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. - -#include -#include -#include - -#include "blosc/blosc.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - if (size < BLOSC_MIN_HEADER_LENGTH) return 0; - - size_t nbytes, cbytes, blocksize; - blosc_cbuffer_sizes(data, &nbytes, &cbytes, &blocksize); - if (cbytes != size) return 0; - if (nbytes == 0) return 0; - - void *output = malloc(nbytes); - blosc_decompress_ctx(data, output, nbytes, /*numinternalthreads=*/1); - free(output); - return 0; -} diff --git a/projects/c-blosc/build.sh b/projects/c-blosc/build.sh index 311ed2cc9..4b1a5a6d3 100755 --- a/projects/c-blosc/build.sh +++ b/projects/c-blosc/build.sh @@ -15,17 +15,15 @@ # ################################################################################ -# build project -mkdir -p build_dir -pushd build_dir -cmake .. +# Build project +cmake . -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" -DBUILD_FUZZERS=ON +make clean make -j$(nproc) -popd -# build fuzzers -for fuzzers in $(find $SRC -name '*_fuzzer.cc'); do - fuzz_basename=$(basename -s .cc $fuzzers) - $CXX $CXXFLAGS -std=c++11 -I. -I../blosc/ \ - $fuzzers $LIB_FUZZING_ENGINE ./build_dir/blosc/libblosc.a \ - -o $OUT/$fuzz_basename -done +# Package seed corpus +zip -j $OUT/decompress_fuzzer_seed_corpus.zip compat/*.cdata + +# Copy the fuzzer executables, zip-ed corpora, and dictionary files to $OUT +find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';' +find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' +find . -name '*_fuzzer_seed_corpus.zip' -exec cp -v '{}' $OUT ';' \ No newline at end of file diff --git a/projects/c-blosc/project.yaml b/projects/c-blosc/project.yaml index c87aa3906..b4c35d813 100644 --- a/projects/c-blosc/project.yaml +++ b/projects/c-blosc/project.yaml @@ -1,9 +1,12 @@ homepage: "https://github.com/Blosc/c-blosc" language: c++ primary_contact: "blosc.oss.fuzz@gmail.com" +auto_ccs: + - "nathan.moinvaziri@gmail.com" sanitizers: - address - memory + - undefined architectures: - x86_64 - i386