From 0619e07fae3234f2721d62eee1459fa1c40ee016 Mon Sep 17 00:00:00 2001 From: spikelin Date: Tue, 11 Jan 2022 14:24:23 +0800 Subject: [PATCH] fix: error in version init --- qcloud-iot-esp8266-demo/main/ota_esp/qcloud_iot_ota_esp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcloud-iot-esp8266-demo/main/ota_esp/qcloud_iot_ota_esp.c b/qcloud-iot-esp8266-demo/main/ota_esp/qcloud_iot_ota_esp.c index 64574df..03024f1 100755 --- a/qcloud-iot-esp8266-demo/main/ota_esp/qcloud_iot_ota_esp.c +++ b/qcloud-iot-esp8266-demo/main/ota_esp/qcloud_iot_ota_esp.c @@ -510,8 +510,8 @@ int enable_ota_task(DeviceInfo *dev_info, void *mqtt_client, char *version) memset(&sg_ota_ctx, 0, sizeof(sg_ota_ctx)); return QCLOUD_ERR_FAILURE; } - memset(sg_ota_ctx.local_version, 0, MAX_SIZE_OF_FW_VERSION + 4); - strncpy(sg_ota_ctx.local_version, version, strlen(version)); + strncpy(sg_ota_ctx.local_version, version, MAX_SIZE_OF_FW_VERSION); + sg_ota_ctx.local_version[MAX_SIZE_OF_FW_VERSION - 1] = '\0'; #else Log_w("OTA on ESP is not enabled!"); #endif