[C++] Add max_depth and max_tables parameters to reflection::Verify (#5815)

* Added missing EndTable() call to VerifyObject()

VerifyObject called VerifyTableStart() but not EndTable(). This made Verifier::VerifyComplexity() increase depth_ with each table, not with the depth of tables.

https://groups.google.com/forum/#!topic/flatbuffers/OpxtW5UFAdg

* Added Check to VerifyAlignment

https://stackoverflow.com/questions/59376308/flatbuffers-verifier-returns-false-without-any-assertion-flatbuffers-debug-veri

* [C++] Add max_depth and max_tables parameters to reflection::Verify

Co-authored-by: Felkel <stefan@eas.local>
Co-authored-by: stefan301 <Stefan.Felkel@de.Zuken.com>
This commit is contained in:
stefan301
2020-03-16 20:19:11 +01:00
committed by GitHub
parent 9b034eee12
commit 8b52af65bc
2 changed files with 7 additions and 3 deletions

View File

@@ -470,7 +470,9 @@ Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
// buf should point to the start of flatbuffer data.
// length specifies the size of the flatbuffer data.
bool Verify(const reflection::Schema &schema, const reflection::Object &root,
const uint8_t *buf, size_t length);
const uint8_t *buf, size_t length,
uoffset_t max_depth = 64,
uoffset_t max_tables = 1000000);
} // namespace flatbuffers

View File

@@ -705,8 +705,10 @@ bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
}
bool Verify(const reflection::Schema &schema, const reflection::Object &root,
const uint8_t *buf, size_t length) {
Verifier v(buf, length);
const uint8_t *buf, size_t length,
uoffset_t max_depth /*= 64*/,
uoffset_t max_tables /*= 1000000*/) {
Verifier v(buf, length, max_depth, max_tables);
return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf), true);
}