Flatbuffer validation

This commit is contained in:
2025-10-15 21:55:20 -04:00
parent 11c3604438
commit 2b235524fe
4 changed files with 16 additions and 11 deletions

View File

@@ -100,6 +100,13 @@ void CommunicationRouter::update_leader() {
}
void CommunicationRouter::route(uint8_t* buffer, const size_t length) const {
flatbuffers::Verifier verifier(buffer, length);
bool ok = Messaging::VerifyMPIMessageBuffer(verifier);
if (!ok) { // This could be moved to just be called on wireline data to save cpu cycles.
ESP_LOGW(TAG, "route: got an invalid MPI message, disregarding");
return;
}
const auto& mpi_message = Flatbuffers::MPIMessageBuilder::parse_mpi_message(buffer);
if (mpi_message->destination() == m_module_id) {