From 7d73efbd316032b906caad255b6f791859e6d5f4 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 8 Nov 2020 20:54:24 +0100 Subject: [PATCH] prevent crash when `send telegram` too short --- src/telegram.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/telegram.cpp b/src/telegram.cpp index 1da3f2170..4fb9e78af 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -429,6 +429,11 @@ void TxService::add(const uint8_t operation, // format is EMS 1.0 (src, dest, type_id, offset, data) // length is the length of the whole telegram data, excluding the CRC void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t length, const bool front) { + // check length + if (length < 5) { + return; + } + // build header. src, dest and offset have fixed positions uint8_t src = data[0]; uint8_t dest = data[1];