From 583cc0b47444d449a1579cd07b93d100bbd13049 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 19 Sep 2020 17:38:08 -0700 Subject: [PATCH 1/2] fix typo --- bt_editor/sidepanel_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bt_editor/sidepanel_editor.cpp b/bt_editor/sidepanel_editor.cpp index 0ecf4ab0..669726b7 100644 --- a/bt_editor/sidepanel_editor.cpp +++ b/bt_editor/sidepanel_editor.cpp @@ -363,7 +363,7 @@ NodeModels SidepanelEditor::importFromXML(QFile* file) if (!file->open(QIODevice::ReadOnly)) { - QMessageBox::warning(this,"Error loading TreeNodeModel form file", + QMessageBox::warning(this,"Error loading TreeNodeModel from file", "The XML was not correctly loaded"); return {}; } From ac5c655a34335dcd0a4d63d4831002eadc596d00 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 19 Sep 2020 18:02:33 -0700 Subject: [PATCH 2/2] proposed fix for issue 95 --- bt_editor/sidepanel_replay.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bt_editor/sidepanel_replay.cpp b/bt_editor/sidepanel_replay.cpp index 5386a374..2a9823c0 100644 --- a/bt_editor/sidepanel_replay.cpp +++ b/bt_editor/sidepanel_replay.cpp @@ -176,8 +176,28 @@ void SidepanelReplay::on_LoadLog() void SidepanelReplay::loadLog(const QByteArray &content) { const char* buffer = reinterpret_cast(content.data()); + + // how many bytes did we read off the disk (uoffset_t aka uint32_t) + const auto read_bytes = content.size(); + + // we need at least 4 bytes to read the bt_header_size + if( read_bytes < 4 ) { + QMessageBox::warning( this, "Log file is empty", + "Failed to load this file.\n" + "This Log file is empty"); + return; + } - size_t bt_header_size = flatbuffers::ReadScalar(buffer); + // read the length of the header section from the file + const size_t bt_header_size = flatbuffers::ReadScalar(buffer); + + // if the length of the header goes past the end of the file, it is invalid + if( (bt_header_size == 0) || (bt_header_size > read_bytes) ) { + QMessageBox::warning( this, "Log file is corrupt", + "Failed to load this file.\n" + "This Log file corrupted or truncated"); + return; + } flatbuffers::Verifier verifier( reinterpret_cast(buffer+4), size_t(content.size() -4));