1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-15 16:23:48 +01:00

Update esphome/core/helpers.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2025-10-11 15:33:46 -10:00
committed by GitHub
parent 3f65f261ab
commit e69013317d

View File

@@ -247,7 +247,7 @@ std::string make_name_with_suffix(const std::string &name, char sep, const char
if (total_len >= MAX_NAME_WITH_SUFFIX_SIZE) { if (total_len >= MAX_NAME_WITH_SUFFIX_SIZE) {
// NOTE: This calculation could underflow if suffix_len >= MAX_NAME_WITH_SUFFIX_SIZE - 2, // NOTE: This calculation could underflow if suffix_len >= MAX_NAME_WITH_SUFFIX_SIZE - 2,
// but this is safe because this helper is only called with small suffixes: // but this is safe because this helper is only called with small suffixes:
// MAC suffixes (6-12 bytes), ".local" (6 bytes), etc. // MAC suffixes (6-12 bytes), ".local" (5 bytes), etc.
name_len = MAX_NAME_WITH_SUFFIX_SIZE - suffix_len - 2; // -2 for separator and null terminator name_len = MAX_NAME_WITH_SUFFIX_SIZE - suffix_len - 2; // -2 for separator and null terminator
total_len = name_len + 1 + suffix_len; total_len = name_len + 1 + suffix_len;
} }