mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 17:48:40 +00:00
Reject empty hostname in validate_hostname
Empty name would cause memcpy underflow in the MAC suffix path. While unlikely in practice, validate explicitly to be safe.
This commit is contained in:
@@ -111,6 +111,8 @@ VALID_INCLUDE_EXTS = {".h", ".hpp", ".tcc", ".ino", ".cpp", ".c"}
|
||||
|
||||
def validate_hostname(config):
|
||||
# Keep in sync with ESPHOME_DEVICE_NAME_MAX_LEN in esphome/core/entity_base.h
|
||||
if not config[CONF_NAME]:
|
||||
raise cv.Invalid("Hostname must not be empty", path=[CONF_NAME])
|
||||
max_length = 31
|
||||
if config[CONF_NAME_ADD_MAC_SUFFIX]:
|
||||
max_length -= 7 # "-AABBCC" is appended when add mac suffix option is used
|
||||
|
||||
Reference in New Issue
Block a user