Skip to content

Commit 0619e07

Browse files
committed
fix: error in version init
1 parent 2b68689 commit 0619e07

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

qcloud-iot-esp8266-demo/main/ota_esp/qcloud_iot_ota_esp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@ int enable_ota_task(DeviceInfo *dev_info, void *mqtt_client, char *version)
510510
memset(&sg_ota_ctx, 0, sizeof(sg_ota_ctx));
511511
return QCLOUD_ERR_FAILURE;
512512
}
513-
memset(sg_ota_ctx.local_version, 0, MAX_SIZE_OF_FW_VERSION + 4);
514-
strncpy(sg_ota_ctx.local_version, version, strlen(version));
513+
strncpy(sg_ota_ctx.local_version, version, MAX_SIZE_OF_FW_VERSION);
514+
sg_ota_ctx.local_version[MAX_SIZE_OF_FW_VERSION - 1] = '\0';
515515
#else
516516
Log_w("OTA on ESP is not enabled!");
517517
#endif

0 commit comments

Comments
 (0)