Increase # of tables threshold in flatbuffer verifier
We were able to encounter AOS configs that exceeded this threshold...
Change-Id: Iac5fe8b2d671d82775701a255f9fee94f9326ff8
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/config_flattener.cc b/aos/config_flattener.cc
index 5bd3cf7..b089d24 100644
--- a/aos/config_flattener.cc
+++ b/aos/config_flattener.cc
@@ -45,7 +45,9 @@
aos::FlatbufferDetachedBuffer<Configuration> merged_config =
configuration::MergeConfiguration(config, schemas);
// In case we've done something overly weird to the flatbuffer...
- CHECK(merged_config.Verify());
+ CHECK(merged_config.Verify())
+ << ": Failed to verify flatbuffer. NOTE: Very large flatbuffers could be "
+ "exceeding max_tables in flatbuffers::Verifier.";
const std::string merged_config_json =
FlatbufferToJson(&merged_config.message(), {.multi_line = true});
diff --git a/third_party/flatbuffers/include/flatbuffers/verifier.h b/third_party/flatbuffers/include/flatbuffers/verifier.h
index 87d3f54..bdc6f36 100644
--- a/third_party/flatbuffers/include/flatbuffers/verifier.h
+++ b/third_party/flatbuffers/include/flatbuffers/verifier.h
@@ -25,11 +25,13 @@
// Helper class to verify the integrity of a FlatBuffer
class Verifier FLATBUFFERS_FINAL_CLASS {
public:
+ static constexpr uoffset_t kDefaultMaxTables = 3000000;
+
struct Options {
// The maximum nesting of tables and vectors before we call it invalid.
uoffset_t max_depth = 64;
// The maximum number of tables we will verify before we call it invalid.
- uoffset_t max_tables = 1000000;
+ uoffset_t max_tables = kDefaultMaxTables;
// If true, verify all data is aligned.
bool check_alignment = true;
// If true, run verifier on nested flatbuffers
@@ -44,7 +46,8 @@
// Deprecated API, please construct with Verifier::Options.
Verifier(const uint8_t *const buf, const size_t buf_len,
- const uoffset_t max_depth = 64, const uoffset_t max_tables = 1000000,
+ const uoffset_t max_depth = 64,
+ const uoffset_t max_tables = kDefaultMaxTables,
const bool check_alignment = true)
: Verifier(buf, buf_len, [&] {
Options opts;