Updated c-blosc to use fuzzers in c-blosc repository. (#4018)

Use compat files for seed corpus with new decompress_fuzzer.
This commit is contained in:
Nathan Moinvaziri 2020-06-22 11:32:53 -07:00 committed by GitHub
parent eedf02164e
commit 351bf4c3c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 46 deletions

View File

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

View File

@ -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 <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#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;
}

View File

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

View File

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