Turn off nested FlatBuffers/FlexBuffers for the fuzzer

this is a temporary fix to allow the fuzzer to work until the real fix of adding a verifier for this is added.
This commit is contained in:
Wouter van Oortmerssen
2021-11-22 16:28:04 -08:00
parent c05f6783a6
commit 4d0e9a8706
3 changed files with 10 additions and 2 deletions

View File

@@ -593,6 +593,8 @@ struct IDLOptions {
bool no_warnings;
std::string project_root;
bool cs_global_alias;
bool json_nested_flatbuffers;
bool json_nested_flexbuffers;
// Possible options for the more general generator below.
enum Language {
@@ -680,6 +682,8 @@ struct IDLOptions {
no_warnings(false),
project_root(""),
cs_global_alias(false),
json_nested_flatbuffers(true),
json_nested_flexbuffers(true),
mini_reflect(IDLOptions::kNone),
require_explicit_ids(false),
lang_to_generate(0),

View File

@@ -264,12 +264,12 @@ struct JsonPrinter {
FLATBUFFERS_ASSERT(IsStruct(fd.value.type) || IsArray(fd.value.type));
val = reinterpret_cast<const Struct *>(table)->GetStruct<const void *>(
fd.value.offset);
} else if (fd.flexbuffer) {
} else if (fd.flexbuffer && opts.json_nested_flexbuffers) {
auto vec = table->GetPointer<const Vector<uint8_t> *>(fd.value.offset);
auto root = flexbuffers::GetRoot(vec->data(), vec->size());
root.ToString(true, opts.strict_json, text);
return true;
} else if (fd.nested_flatbuffer) {
} else if (fd.nested_flatbuffer && opts.json_nested_flatbuffers) {
auto vec = table->GetPointer<const Vector<uint8_t> *>(fd.value.offset);
auto root = GetRoot<Table>(vec->data());
return GenStruct(*fd.nested_flatbuffer, root, indent);

View File

@@ -80,6 +80,10 @@ std::string do_test(const flatbuffers::IDLOptions &opts,
flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
parser.builder_.GetSize());
TEST_EQ(true, MyGame::Example::VerifyMonsterBuffer(verifier));
// FIXME: these are currently not being properly verified, so turn them off
// for fuzzing until they are.
parser.opts.json_nested_flatbuffers = false;
parser.opts.json_nested_flexbuffers = false;
TEST_ASSERT(
GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen));
} else if (check_parser) {