fix deviceName length (#2482), formatting

This commit is contained in:
MichaelDvP
2025-03-28 09:39:38 +01:00
parent c927e5f496
commit d405478a13

View File

@@ -975,7 +975,9 @@ void EMSESP::process_deviceName(std::shared_ptr<const Telegram> telegram) {
return;
}
char name[16];
uint8_t len = telegram->offset + telegram->message_length - 27;
// len including zero terminator, if there is one, otherwise copy to end of telegram
// https://github.com/emsesp/EMS-ESP32/discussions/2482#discussioncomment-12649817
uint8_t len = telegram->offset + telegram->message_length - 26;
strlcpy(name, (const char *)&telegram->message_data[27 - telegram->offset], len < 16 ? len : 16);
char * c = name;
while (isprint(*c)) {