From c8a6ce79ea52e616a32d1c96d1682ddf2545e213 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 8 Mar 2017 18:37:03 +0100 Subject: [PATCH] :ambulance: fixing fuzzers to work with new exceptions --- test/src/fuzzer-parse_cbor.cpp | 12 ++++-------- test/src/fuzzer-parse_msgpack.cpp | 12 ++++-------- test/src/unit-cbor.cpp | 2 -- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/test/src/fuzzer-parse_cbor.cpp b/test/src/fuzzer-parse_cbor.cpp index 30fa69779..6e7ae6362 100644 --- a/test/src/fuzzer-parse_cbor.cpp +++ b/test/src/fuzzer-parse_cbor.cpp @@ -44,23 +44,19 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // deserializations must match assert(j1 == j2); } - catch (const std::invalid_argument&) + catch (const json::parse_error&) { // parsing a CBOR serialization must not fail assert(false); } } - catch (const std::invalid_argument&) + catch (const json::parse_error&) { // parse errors are ok, because input may be random bytes } - catch (const std::out_of_range&) + catch (const json::type_error&) { - // parse errors are ok, because input may be random bytes - } - catch (const std::domain_error&) - { - // parse errors are ok, because input may be random bytes + // type errors can occur during parsing, too } // return 0 - non-zero return values are reserved for future use diff --git a/test/src/fuzzer-parse_msgpack.cpp b/test/src/fuzzer-parse_msgpack.cpp index bf2fcab07..420283a40 100644 --- a/test/src/fuzzer-parse_msgpack.cpp +++ b/test/src/fuzzer-parse_msgpack.cpp @@ -44,23 +44,19 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // deserializations must match assert(j1 == j2); } - catch (const std::invalid_argument&) + catch (const json::parse_error&) { // parsing a MessagePack serialization must not fail assert(false); } } - catch (const std::invalid_argument&) + catch (const json::parse_error&) { // parse errors are ok, because input may be random bytes } - catch (const std::out_of_range&) + catch (const json::type_error&) { - // parse errors are ok, because input may be random bytes - } - catch (const std::domain_error&) - { - // parse errors are ok, because input may be random bytes + // type errors can occur during parsing, too } // return 0 - non-zero return values are reserved for future use diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 32464ae71..87cbadc20 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -1358,8 +1358,6 @@ TEST_CASE("CBOR regressions", "[!throws]") { // exotic edge case CHECK_THROWS_AS(json::check_length(0xffffffffffffffffull, 0xfffffffffffffff0ull, 0xff), json::parse_error); - CHECK_THROWS_WITH(json::check_length(0xffffffffffffffffull, 0xfffffffffffffff0ull, 0xff), - "[json.exception.parse_error.110] parse error at 256: cannot read 18446744073709551600 bytes from vector"); } }