diff options
Diffstat (limited to 'tests/fuzzer/flatbuffers_monster_fuzzer.cc')
-rw-r--r-- | tests/fuzzer/flatbuffers_monster_fuzzer.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/fuzzer/flatbuffers_monster_fuzzer.cc b/tests/fuzzer/flatbuffers_monster_fuzzer.cc index 13bdef91..2b050487 100644 --- a/tests/fuzzer/flatbuffers_monster_fuzzer.cc +++ b/tests/fuzzer/flatbuffers_monster_fuzzer.cc @@ -26,6 +26,9 @@ namespace { +static constexpr size_t kMinInputLength = 1; +static constexpr size_t kMaxInputLength = 99000; + static constexpr uint8_t flags_strict_json = 0x80; static constexpr uint8_t flags_skip_unexpected_fields_in_json = 0x40; static constexpr uint8_t flags_allow_non_utf8 = 0x20; @@ -83,7 +86,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { const std::string original(reinterpret_cast<const char *>(data), size); auto input = std::string(original.c_str()); // until '\0' - if (input.empty()) return 0; + if (input.size() < kMinInputLength || input.size() > kMaxInputLength) + return 0; flatbuffers::IDLOptions opts; opts.strict_json = (flags & flags_strict_json); |