mirror of https://github.com/google/oss-fuzz.git
[msgpack-c] Get the fuzzers from the source repo, use a for loop for future fuzzers (#1359)
This commit is contained in:
parent
e01619962e
commit
37ced73db3
|
@ -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/
|
||||
|
|
|
@ -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/"
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue