diff options
author | stefan301 <32997632+stefan301@users.noreply.github.com> | 2020-03-16 20:19:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-16 12:19:11 -0700 |
commit | 8b52af65bc066fb36761ebc1f950454c5e5ef548 (patch) | |
tree | 287a5517692601f8418c8eaf9da2a5d4a516a7c9 | |
parent | 9b034eee126f837e4cf2eabbeace87507337e4b0 (diff) | |
download | flatbuffers-8b52af65bc066fb36761ebc1f950454c5e5ef548.tar.gz flatbuffers-8b52af65bc066fb36761ebc1f950454c5e5ef548.tar.bz2 flatbuffers-8b52af65bc066fb36761ebc1f950454c5e5ef548.zip |
[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>
-rw-r--r-- | include/flatbuffers/reflection.h | 4 | ||||
-rw-r--r-- | src/reflection.cpp | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/include/flatbuffers/reflection.h b/include/flatbuffers/reflection.h index 052e6d92..f606b7b5 100644 --- a/include/flatbuffers/reflection.h +++ b/include/flatbuffers/reflection.h @@ -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 diff --git a/src/reflection.cpp b/src/reflection.cpp index 77ea0dcf..abe9bb5d 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -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); } |