Merge pull request #972 from kovdan01/fix_fuzz_running

Fix #969
This commit is contained in:
Takatoshi Kondo 2021-08-31 09:24:20 +09:00 committed by GitHub
commit c0708dbcba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -38,7 +38,7 @@ void UnpackPackFuzzerRegressionTest(const std::string& fpath) {
std::vector<char> bytes(length); std::vector<char> bytes(length);
in.read(bytes.data(), bytes.size()); in.read(bytes.data(), bytes.size());
BOOST_REQUIRE(in); BOOST_REQUIRE(in);
BOOST_REQUIRE_EQUAL(0, FuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()), bytes.size())); BOOST_REQUIRE_EQUAL(0, LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()), bytes.size()));
} }
boost::unit_test::test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) boost::unit_test::test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[])

View File

@ -1,6 +1,10 @@
#include <msgpack.hpp> #include <msgpack.hpp>
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 { try {
// NOTE(derwolfe): by default the limits are set at 2^32-1 length. I'm // NOTE(derwolfe): by default the limits are set at 2^32-1 length. I'm
// setting these at far smaller values to avoid OOMs // setting these at far smaller values to avoid OOMs

View File

@ -5,5 +5,5 @@
BOOST_AUTO_TEST_CASE(works) BOOST_AUTO_TEST_CASE(works)
{ {
BOOST_CHECK_EQUAL(0, FuzzerTestOneInput(MSGPACK_NULLPTR, 0)); BOOST_CHECK_EQUAL(0, LLVMFuzzerTestOneInput(MSGPACK_NULLPTR, 0));
} }