From c58bc87b94f7004524f42a210fa70e9bfbdf40ef Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Sun, 10 Mar 2024 15:49:29 +0530 Subject: [PATCH] Fix battery replacement description and active locale attributes --- components/esp_matter/esp_matter_attribute.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index 89bb214ec..8316ba489 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -3330,9 +3330,13 @@ namespace attribute { attribute_t *create_active_locale(cluster_t *cluster, char *value, uint16_t length) { + if (length > k_max_active_locale_length) { + ESP_LOGE(TAG, "Could not create attribute, string length out of bound"); + return NULL; + } return esp_matter::attribute::create(cluster, LocalizationConfiguration::Attributes::ActiveLocale::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE, - esp_matter_char_str(value, length)); + esp_matter_char_str(value, length), k_max_active_locale_length); } attribute_t *create_supported_locales(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) @@ -3854,7 +3858,7 @@ attribute_t *create_active_bat_faults(cluster_t *cluster, uint8_t * value, uint1 attribute_t *create_bat_replacement_description(cluster_t *cluster, const char * value, uint16_t length) { - if (length > k_max_description_length) { + if (length > k_max_bat_replacement_description_length) { ESP_LOGE(TAG, "Could not create attribute, string size out of bound"); return NULL; }