Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug:OTA相关 #140

Open
LeeSSXX opened this issue Apr 16, 2019 · 1 comment
Open

Bug:OTA相关 #140

LeeSSXX opened this issue Apr 16, 2019 · 1 comment

Comments

@LeeSSXX
Copy link

LeeSSXX commented Apr 16, 2019

iotkit-embedded/src/services/linkkit/dm/dm_fota.c 这个文件中的66行有一个bug。

    int res = 0, file_download = 0;
    uint32_t file_size = 0, file_downloaded = 0;
    uint32_t percent_pre = 0, percent_now = 0;
    unsigned long long report_pre = 0, report_now = 0;
    dm_fota_ctx_t *ctx = _dm_fota_get_ctx();

file_downloaded及file_size的大小默认是unit32_t类型,这个类型的最大值为4294967295
也就是文件可以最大4个G,这对于固件应该不是问题,但往下看。

        /* Get OTA information */
        IOT_OTA_Ioctl(ota_handle, IOT_OTAG_FETCHED_SIZE, &file_downloaded, 4);
        IOT_OTA_Ioctl(ota_handle, IOT_OTAG_FILE_SIZE, &file_size, 4);

        /* Calculate Download Percent And Update Report Timestamp*/
        percent_now = (file_downloaded * 100) / file_size;
        report_now = HAL_UptimeMs();

        /* Report Download Process To Cloud */
        if (report_now < report_pre) {
            report_pre = report_now;
        }

percent_now = (file_downloaded * 100) / file_size;
因为这里面乘以100,如果固件大于42M,造成数据溢出。就会造成更新进度异常。
所以只需要改一下
uint32_t file_size = 0, file_downloaded = 0;

uint64_t file_size = 0, file_downloaded = 0;

@fenghr1219
Copy link

感谢您对反馈 我们已经将您的建议反馈给研发的同学

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants