mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 22:32:02 +00:00
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:
@@ -593,6 +593,8 @@ struct IDLOptions {
|
|||||||
bool no_warnings;
|
bool no_warnings;
|
||||||
std::string project_root;
|
std::string project_root;
|
||||||
bool cs_global_alias;
|
bool cs_global_alias;
|
||||||
|
bool json_nested_flatbuffers;
|
||||||
|
bool json_nested_flexbuffers;
|
||||||
|
|
||||||
// Possible options for the more general generator below.
|
// Possible options for the more general generator below.
|
||||||
enum Language {
|
enum Language {
|
||||||
@@ -680,6 +682,8 @@ struct IDLOptions {
|
|||||||
no_warnings(false),
|
no_warnings(false),
|
||||||
project_root(""),
|
project_root(""),
|
||||||
cs_global_alias(false),
|
cs_global_alias(false),
|
||||||
|
json_nested_flatbuffers(true),
|
||||||
|
json_nested_flexbuffers(true),
|
||||||
mini_reflect(IDLOptions::kNone),
|
mini_reflect(IDLOptions::kNone),
|
||||||
require_explicit_ids(false),
|
require_explicit_ids(false),
|
||||||
lang_to_generate(0),
|
lang_to_generate(0),
|
||||||
|
|||||||
@@ -264,12 +264,12 @@ struct JsonPrinter {
|
|||||||
FLATBUFFERS_ASSERT(IsStruct(fd.value.type) || IsArray(fd.value.type));
|
FLATBUFFERS_ASSERT(IsStruct(fd.value.type) || IsArray(fd.value.type));
|
||||||
val = reinterpret_cast<const Struct *>(table)->GetStruct<const void *>(
|
val = reinterpret_cast<const Struct *>(table)->GetStruct<const void *>(
|
||||||
fd.value.offset);
|
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 vec = table->GetPointer<const Vector<uint8_t> *>(fd.value.offset);
|
||||||
auto root = flexbuffers::GetRoot(vec->data(), vec->size());
|
auto root = flexbuffers::GetRoot(vec->data(), vec->size());
|
||||||
root.ToString(true, opts.strict_json, text);
|
root.ToString(true, opts.strict_json, text);
|
||||||
return true;
|
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 vec = table->GetPointer<const Vector<uint8_t> *>(fd.value.offset);
|
||||||
auto root = GetRoot<Table>(vec->data());
|
auto root = GetRoot<Table>(vec->data());
|
||||||
return GenStruct(*fd.nested_flatbuffer, root, indent);
|
return GenStruct(*fd.nested_flatbuffer, root, indent);
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ std::string do_test(const flatbuffers::IDLOptions &opts,
|
|||||||
flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
|
flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
|
||||||
parser.builder_.GetSize());
|
parser.builder_.GetSize());
|
||||||
TEST_EQ(true, MyGame::Example::VerifyMonsterBuffer(verifier));
|
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(
|
TEST_ASSERT(
|
||||||
GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen));
|
GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen));
|
||||||
} else if (check_parser) {
|
} else if (check_parser) {
|
||||||
|
|||||||
Reference in New Issue
Block a user