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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user