Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ static bool VerifyObject(flatbuffers::Verifier& v,
return false;
}
} else {
if (!table->VerifyField<uoffset_t>(v, field_def->offset(),
sizeof(uoffset_t)))
return false;
if (!VerifyObject(v, schema, *child_obj,
flatbuffers::GetFieldT(*table, *field_def),
field_def->required())) {
Expand All @@ -249,6 +252,9 @@ static bool VerifyObject(flatbuffers::Verifier& v,
break;
}
case reflection::Union: {
if (!table->VerifyField<uoffset_t>(v, field_def->offset(),
sizeof(uoffset_t)))
return false;
// get union type from the prev field
voffset_t utype_offset = field_def->offset() - sizeof(voffset_t);
auto utype = table->GetField<uint8_t>(utype_offset, 0);
Expand Down Expand Up @@ -786,6 +792,7 @@ Offset<const Table*> CopyTable(FlatBufferBuilder& fbb,
bool Verify(const reflection::Schema& schema, const reflection::Object& root,
const uint8_t* const buf, const size_t length,
const uoffset_t max_depth, const uoffset_t max_tables) {
if (length < sizeof(uoffset_t)) return false;
Verifier v(buf, length, max_depth, max_tables);
return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf),
/*required=*/true);
Expand All @@ -795,6 +802,7 @@ bool VerifySizePrefixed(const reflection::Schema& schema,
const reflection::Object& root,
const uint8_t* const buf, const size_t length,
const uoffset_t max_depth, const uoffset_t max_tables) {
if (length < sizeof(uoffset_t) * 2) return false;
Verifier v(buf, length, max_depth, max_tables);
return VerifyObject(v, schema, root, flatbuffers::GetAnySizePrefixedRoot(buf),
/*required=*/true);
Expand Down
Loading