diff options
author | 2018-04-25 10:46:19 -0500 | |
---|---|---|
committer | 2018-04-25 08:46:19 -0700 | |
commit | 37ced73db377e1d87594be996a97a5faaacfd137 (patch) | |
tree | 5160fb0e7e21c587f58a49dcc4393d3deefe6556 /projects/msgpack-c | |
parent | e01619962ed33bce27e0d8a6b2c04e624967d531 (diff) |
[msgpack-c] Get the fuzzers from the source repo, use a for loop for future fuzzers (#1359)
Diffstat (limited to 'projects/msgpack-c')
-rw-r--r-- | projects/msgpack-c/Dockerfile | 2 | ||||
-rwxr-xr-x | projects/msgpack-c/build.sh | 9 | ||||
-rw-r--r-- | projects/msgpack-c/unpack_pack_fuzzer.cc | 21 |
3 files changed, 7 insertions, 25 deletions
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 <msgpack.hpp> - -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<const char *>(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; -} |