From 0dacd2c71f5051744fd31e44cb520c1cb53e1b6e Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 18 May 2026 20:55:57 +0200 Subject: [PATCH] don't allocate ariable size on stack --- src/core/telegram.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/telegram.cpp b/src/core/telegram.cpp index 9317882c9..a52e858e4 100644 --- a/src/core/telegram.cpp +++ b/src/core/telegram.cpp @@ -572,12 +572,11 @@ bool TxService::send_raw(const char * telegram_data) { return false; } - // since the telegram data is a const, make a copy. add 1 to grab the \0 EOS - char telegram[strlen(telegram_data) + 1]; - strlcpy(telegram, telegram_data, sizeof(telegram)); + // since the telegram data is a const, make a copy + char * telegram = strdup(telegram_data); uint8_t count = 0; - uint8_t data[2 + strlen(telegram) / 3]; + uint8_t data[256]; // max raw telegram length // get values char * p = strtok(telegram, " ,"); // delimiter @@ -585,7 +584,7 @@ bool TxService::send_raw(const char * telegram_data) { data[count++] = (uint8_t)strtol(p, 0, 16); p = strtok(nullptr, " ,"); } - + free(telegram); // check valid length if (count < 4) { return false;