Fix telnet buffer overrun detection

This commit is contained in:
Theo Arends 2025-03-28 12:16:32 +01:00
parent b77b622fbe
commit 289120ee92
3 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;
}
}