From a49644ab7487c7e1b41959da0ff21476d535976c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 28 May 2018 17:57:22 +0200 Subject: [PATCH] :ambulance: adjusted Fuzzer to new parser out_of_range exceptions where unexpected before - the parser used to crash in these situations... --- test/src/fuzzer-parse_cbor.cpp | 4 ++++ test/src/fuzzer-parse_json.cpp | 4 ++++ test/src/fuzzer-parse_msgpack.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/test/src/fuzzer-parse_cbor.cpp b/test/src/fuzzer-parse_cbor.cpp index 0520ae7c..45dd01f3 100644 --- a/test/src/fuzzer-parse_cbor.cpp +++ b/test/src/fuzzer-parse_cbor.cpp @@ -58,6 +58,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // type errors can occur during parsing, too } + catch (const json::out_of_range&) + { + // out of range errors can occur during parsing, too + } // return 0 - non-zero return values are reserved for future use return 0; diff --git a/test/src/fuzzer-parse_json.cpp b/test/src/fuzzer-parse_json.cpp index 2d13c26b..0694bb70 100644 --- a/test/src/fuzzer-parse_json.cpp +++ b/test/src/fuzzer-parse_json.cpp @@ -63,6 +63,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // parse errors are ok, because input may be random bytes } + catch (const json::out_of_range&) + { + // out of range errors may happen if provided sizes are excessive + } // return 0 - non-zero return values are reserved for future use return 0; diff --git a/test/src/fuzzer-parse_msgpack.cpp b/test/src/fuzzer-parse_msgpack.cpp index 6f98409f..c274816a 100644 --- a/test/src/fuzzer-parse_msgpack.cpp +++ b/test/src/fuzzer-parse_msgpack.cpp @@ -58,6 +58,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // type errors can occur during parsing, too } + catch (const json::out_of_range&) + { + // out of range errors may happen if provided sizes are excessive + } // return 0 - non-zero return values are reserved for future use return 0;