From 289120ee92e83df175076eb888c28f5e24871372 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 28 Mar 2025 12:16:32 +0100 Subject: [PATCH] Fix telnet buffer overrun detection --- CHANGELOG.md | 2 +- RELEASENOTES.md | 3 ++- tasmota/tasmota_xdrv_driver/xdrv_78_telnet.ino | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2039ea9bf..e86b19504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ## [14.5.0.3] ### Added - Extend command `GPIO` with different display options and allowing updating of module GPIO's in one go -- Berry `bytes.add()` now accepts 3-bytes values +- Berry `bytes.add()` now accepts 3-bytes values (#23200) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 6d5a83564..4e56a01c1 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -126,7 +126,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Berry `introspect.solidified()` to know if a Berry object is solidified or in RAM [#23063](https://github.com/arendst/Tasmota/issues/23063) - Berry `global.undef()` to undefine a global variable [#23073](https://github.com/arendst/Tasmota/issues/23073) - Berry load `.tapp` files in `/.extensions/` then in `/` [#23113](https://github.com/arendst/Tasmota/issues/23113) -- Berry `re.dump()` (#23162)[#23162](https://github.com/arendst/Tasmota/issues/23162) +- Berry `re.dump()` [#23162](https://github.com/arendst/Tasmota/issues/23162) +- Berry `bytes.add()` now accepts 3-bytes values [#23200](https://github.com/arendst/Tasmota/issues/23200) - Matter prepare for ICD cluster [#23158](https://github.com/arendst/Tasmota/issues/23158) - LVGL experimental mirroring of display on Web UI [#23041](https://github.com/arendst/Tasmota/issues/23041) - HASPmota autostart when `pages.jsonl` exists [#23181](https://github.com/arendst/Tasmota/issues/23181) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_78_telnet.ino b/tasmota/tasmota_xdrv_driver/xdrv_78_telnet.ino index cf38bdc80..a6620d3b0 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_78_telnet.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_78_telnet.ino @@ -86,6 +86,7 @@ struct { uint8_t color[3]; bool ip_filter_enabled; bool color_disable; + bool overrun; } Telnet; /********************************************************************************************/ @@ -126,9 +127,7 @@ void TelnetGetLog(void) { uint32_t index = Telnet.log_index; // Dump log buffer char* line; size_t len; - bool any_line = false; while (GetLog(TasmotaGlobal.seriallog_level, &index, &line, &len)) { - any_line = true; TelnetWrite(line, len -1); } Telnet.log_index = index; @@ -185,6 +184,8 @@ void TelnetLoop(void) { if (isprint(in_byte)) { // Any char between 32 and 127 if (Telnet.in_byte_counter < Telnet.buffer_size -1) { // Add char to string if it still fits Telnet.buffer[Telnet.in_byte_counter++] = in_byte; + } else { + Telnet.overrun = true; } } else if (in_byte == '\n') { @@ -192,7 +193,7 @@ void TelnetLoop(void) { Telnet.buffer[Telnet.in_byte_counter] = 0; // Telnet data completed Telnet.prompt = 1; // Print prompt after requested data and use response color SetMinimumSeriallog(); - if (Telnet.in_byte_counter >= Telnet.buffer_size) { + if (Telnet.overrun) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Buffer overrun")); } else { char command[CMDSZ]; @@ -205,6 +206,7 @@ void TelnetLoop(void) { } } Telnet.in_byte_counter = 0; + Telnet.overrun = false; return; } }