From 0d94cefe4b84f1eb81d7fc852ed2e74c36dabd11 Mon Sep 17 00:00:00 2001 From: zhangwenxu Date: Thu, 6 Jul 2023 21:04:01 +0800 Subject: [PATCH] fix(openthread): fix ot settings out of range issue --- components/openthread/src/port/esp_openthread_settings.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/openthread/src/port/esp_openthread_settings.c b/components/openthread/src/port/esp_openthread_settings.c index 8f877bd724fb..8bc08be48206 100644 --- a/components/openthread/src/port/esp_openthread_settings.c +++ b/components/openthread/src/port/esp_openthread_settings.c @@ -153,7 +153,9 @@ otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint if (ret != ESP_OK) { return OT_ERROR_NOT_FOUND; } - ret = nvs_get_blob(s_ot_nvs_handle, ot_nvs_key, aValue, (size_t *)aValueLength); + size_t length = *aValueLength; + ret = nvs_get_blob(s_ot_nvs_handle, ot_nvs_key, aValue, &length); + *aValueLength = (uint16_t) length; ESP_RETURN_ON_FALSE((ret == ESP_OK), OT_ERROR_NOT_FOUND, OT_PLAT_LOG_TAG, "Data not found, err: %d", ret); return OT_ERROR_NONE; }