From 9c2af6318ced3de3927db404172fe358fd0afa7d Mon Sep 17 00:00:00 2001 From: Sergey Dudanov Date: Wed, 26 Jun 2024 14:38:11 +0400 Subject: [PATCH] [modbus-text-sensor] fix potential buffer overflow (#6993) --- .../modbus_controller/text_sensor/modbus_textsensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp index 359c6e2f50..da5c0fba37 100644 --- a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +++ b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp @@ -15,7 +15,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector &data) { std::ostringstream output; uint8_t items_left = this->response_bytes; uint8_t index = this->offset; - char buffer[4]; + char buffer[5]; while ((items_left > 0) && index < data.size()) { uint8_t b = data[index]; switch (this->encode_) {