From f6137311836747b029e200fa80072c56af2d8c5e Mon Sep 17 00:00:00 2001 From: Yurii Date: Mon, 19 Oct 2026 04:10:21 +0300 Subject: [PATCH] fix: prevent hangs when processing long sensor names --- src/Sensors.h | 2 +- src/utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sensors.h b/src/Sensors.h index a77d7bd..fd40a1f 100644 --- a/src/Sensors.h +++ b/src/Sensors.h @@ -409,7 +409,7 @@ public: static String& cleanName(String& value, char space = ' ') { // only valid symbols - for (uint8_t pos = 0; pos < value.length(); pos++) { + for (size_t pos = 0; pos < value.length(); pos++) { char symbol = value.charAt(pos); // 0..9 diff --git a/src/utils.h b/src/utils.h index 4816606..9553bd8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1885,7 +1885,7 @@ bool jsonToSensorSettings(const uint8_t sensorId, const JsonVariantConst src, Se } // name - if (!src[FPSTR(S_NAME)].isNull()) { + if (src[FPSTR(S_NAME)].is() && src[FPSTR(S_NAME)].as().size() < sizeof(dst.name)) { auto value = src[FPSTR(S_NAME)].as(); Sensors::cleanName(value);