[modbus-text-sensor] fix potential buffer overflow (#6993)

This commit is contained in:
Sergey Dudanov 2024-06-26 14:38:11 +04:00 committed by GitHub
parent 91766afb64
commit 01bcf5fb97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,7 +15,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &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_) {