From 4ea4d6912395bca7f5455b8998b2f3cfb77a3610 Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 30 Aug 2021 21:45:50 +0300 Subject: [PATCH] Fix #969 --- fuzz/regression_runner.cpp | 2 +- fuzz/unpack_pack_fuzzer.cpp | 6 +++++- test/fuzz_unpack_pack_fuzzer_cpp11.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fuzz/regression_runner.cpp b/fuzz/regression_runner.cpp index 08aedd1b..3f423bea 100644 --- a/fuzz/regression_runner.cpp +++ b/fuzz/regression_runner.cpp @@ -38,7 +38,7 @@ void UnpackPackFuzzerRegressionTest(const std::string& fpath) { std::vector bytes(length); in.read(bytes.data(), bytes.size()); BOOST_REQUIRE(in); - BOOST_REQUIRE_EQUAL(0, FuzzerTestOneInput(reinterpret_cast(bytes.data()), bytes.size())); + BOOST_REQUIRE_EQUAL(0, LLVMFuzzerTestOneInput(reinterpret_cast(bytes.data()), bytes.size())); } boost::unit_test::test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) diff --git a/fuzz/unpack_pack_fuzzer.cpp b/fuzz/unpack_pack_fuzzer.cpp index 032db43d..b74f2cb3 100644 --- a/fuzz/unpack_pack_fuzzer.cpp +++ b/fuzz/unpack_pack_fuzzer.cpp @@ -1,6 +1,10 @@ #include -extern "C" int FuzzerTestOneInput(const uint8_t *data, size_t size) { +// The function's signature must NOT be changed since other projects rely on it: +// - libFuzzer +// - AFL++ +// - Google's oss-fuzz (uses the previous two ones) +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 diff --git a/test/fuzz_unpack_pack_fuzzer_cpp11.cpp b/test/fuzz_unpack_pack_fuzzer_cpp11.cpp index 6bc89448..69d72fa3 100644 --- a/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +++ b/test/fuzz_unpack_pack_fuzzer_cpp11.cpp @@ -5,5 +5,5 @@ BOOST_AUTO_TEST_CASE(works) { - BOOST_CHECK_EQUAL(0, FuzzerTestOneInput(MSGPACK_NULLPTR, 0)); + BOOST_CHECK_EQUAL(0, LLVMFuzzerTestOneInput(MSGPACK_NULLPTR, 0)); }