From 37ced73db377e1d87594be996a97a5faaacfd137 Mon Sep 17 00:00:00 2001 From: Chris Wolfe Date: Wed, 25 Apr 2018 10:46:19 -0500 Subject: [msgpack-c] Get the fuzzers from the source repo, use a for loop for future fuzzers (#1359) --- projects/msgpack-c/Dockerfile | 2 +- projects/msgpack-c/build.sh | 9 ++++++--- projects/msgpack-c/unpack_pack_fuzzer.cc | 21 --------------------- 3 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 projects/msgpack-c/unpack_pack_fuzzer.cc (limited to 'projects/msgpack-c') diff --git a/projects/msgpack-c/Dockerfile b/projects/msgpack-c/Dockerfile index d92f00fd..46727662 100644 --- a/projects/msgpack-c/Dockerfile +++ b/projects/msgpack-c/Dockerfile @@ -20,4 +20,4 @@ RUN apt-get update && apt-get install -y cmake RUN git clone --depth 1 https://github.com/msgpack/msgpack-c.git msgpack-c RUN git clone --depth 1 https://github.com/derwolfe/msgpack-corpora.git msgpack-corpora WORKDIR msgpack-c -COPY build.sh unpack_pack_fuzzer.cc $SRC/ +COPY build.sh $SRC/ diff --git a/projects/msgpack-c/build.sh b/projects/msgpack-c/build.sh index 3a28125f..df5126e6 100755 --- a/projects/msgpack-c/build.sh +++ b/projects/msgpack-c/build.sh @@ -20,8 +20,11 @@ cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ -DMSGPACK_CXX11=ON . make -j$(nproc) all -$CXX $CXXFLAGS -std=c++11 -Iinclude -I"$SRC/msgpack-c/include" \ - "$SRC/unpack_pack_fuzzer.cc" -o "$OUT/unpack_pack_fuzzer" \ - -lFuzzingEngine "$SRC/msgpack-c/libmsgpackc.a" +for f in $SRC/msgpack-c/fuzz/*_fuzzer.cpp; do + fuzzer=$(basename "$f" _fuzzer.cpp) + $CXX $CXXFLAGS -std=c++11 -Iinclude -I"$SRC/msgpack-c/include" \ + "$f" -o "$OUT/${fuzzer}_fuzzer" \ + -lFuzzingEngine "$SRC/msgpack-c/libmsgpackc.a" +done zip -rj "$OUT/unpack_pack_fuzzer_seed_corpus.zip" "$SRC/msgpack-corpora/packed/" diff --git a/projects/msgpack-c/unpack_pack_fuzzer.cc b/projects/msgpack-c/unpack_pack_fuzzer.cc deleted file mode 100644 index 7f967331..00000000 --- a/projects/msgpack-c/unpack_pack_fuzzer.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - try { - // NOTE(derwolfe): by default the limits are set at 2^32-1 length. I'm - // setting these at far smaller values to avoid OOMs - const int test_limit = 10000; - msgpack::object_handle unpacked = msgpack::unpack(reinterpret_cast(data), - size, - nullptr, - nullptr, - msgpack::unpack_limit(test_limit, - test_limit, - test_limit, - test_limit)); - msgpack::sbuffer sbuf; - msgpack::pack(sbuf, unpacked.get()); - } catch (...) { - } - return 0; -} -- cgit v1.2.3