thor: Fix the bug upon file size recovery 45/245745/1 accepted/tizen/unified/20201028.123845 submit/tizen/20201027.003535
authorJunghoon Kim <jhoon20.kim@samsung.com>
Thu, 15 Oct 2020 07:55:00 +0000 (16:55 +0900)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Thu, 15 Oct 2020 07:55:00 +0000 (16:55 +0900)
TFM throws a flashing error for files larger than 2 GBytes. Fix the
calculation logic for the file size recovery.

Change-Id: I28ec141dec63cfe495dcb6a5bcbe03323de36947
Signed-off-by: Junghoon Kim <jhoon20.kim@samsung.com>
src/thor.c

index 097b7bc2c05a1f5f6ff9f690647794b38c63b593..8aa7d6145d2679f68bc58a89924989d235aa8658 100644 (file)
@@ -234,8 +234,8 @@ static int thor_process_rqt_download(struct thor_context *tctx)
                struct dfu_context *dfu = tctx->dfu;
                uint64_t total_size;
 
-               total_size = (uint64_t)rqt->int_data[0]
-                                       + ((uint64_t)rqt->int_data[1] << 32);
+               total_size = (((uint64_t)(uint32_t)rqt->int_data[1] << 32)
+                                       | (uint32_t)rqt->int_data[0]);
 
                dfu_init_download(dfu, total_size);
                break;
@@ -255,8 +255,8 @@ static int thor_process_rqt_download(struct thor_context *tctx)
                        break;
                }
 
-               file_size = (uint64_t)rqt->int_data[1]
-                                       + ((uint64_t)rqt->int_data[2] << 32);
+               file_size = (((uint64_t)(uint32_t)rqt->int_data[2] << 32)
+                                       | (uint32_t)rqt->int_data[1]);
 
                memcpy(f_name, rqt->str_data[0], FILE_NAME_MAXLEN);