From 63ab7bec69350fad9e6a674a4bdd604fac48405a Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 13 Jul 2024 11:49:47 -0500 Subject: [PATCH] AP_HAL_ESP32: use correct unformatted system ID length Avoids stuffing uninitialized data into the ID. --- libraries/AP_HAL_ESP32/Util.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/AP_HAL_ESP32/Util.cpp b/libraries/AP_HAL_ESP32/Util.cpp index 2eab971532..7a3cf34587 100644 --- a/libraries/AP_HAL_ESP32/Util.cpp +++ b/libraries/AP_HAL_ESP32/Util.cpp @@ -243,15 +243,13 @@ bool Util::get_system_id(char buf[50]) bool Util::get_system_id_unformatted(uint8_t buf[], uint8_t &len) { - len = MIN(12, len); - - uint8_t base_mac_addr[6] = {0}; esp_err_t ret = esp_efuse_mac_get_custom(base_mac_addr); if (ret != ESP_OK) { ret = esp_efuse_mac_get_default(base_mac_addr); } + len = MIN(len, ARRAY_SIZE(base_mac_addr)); memcpy(buf, (const void *)base_mac_addr, len); return true;