thor: Support file name longer than 32 39/297739/3 accepted/tizen/unified/20230825.121028 accepted/tizen/unified/riscv/20230828.003408
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 23 Aug 2023 10:53:13 +0000 (19:53 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 24 Aug 2023 02:29:49 +0000 (11:29 +0900)
The lthor tool sends maxium 64 length file name with two
str_data[] elements. If the 32nd character of str_data[0] is not
'\0', then it can be longer than 32, so copy str_data[1] also.

Change-Id: Ia95a2a16fc2ad876834d504c558e3f2fcce11119
Ref: https://git.tizen.org/cgit/tools/lthor/commit/?id=7da7ee14ea6eed60274ef3d65d16e842547bbd3e
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
packaging/initrd-flash.spec
src/thor-proto.h
src/thor.c

index 27314b7..24e44ca 100644 (file)
@@ -1,6 +1,6 @@
 Name:       initrd-flash
 Summary:    Advanced flash-manager, package for building ramdisk-recovery.img
-Version:    0.0.4
+Version:    0.0.5
 Release:    0
 Group:      System/Utilities
 License:    Apache-2.0
index 04cefbe..8f6211a 100644 (file)
@@ -91,7 +91,8 @@ struct data_res_pkt {
 #define RES_PKT_SIZE           sizeof(struct res_pkt)
 #define DATA_RES_PKT_SIZE      sizeof(struct data_res_pkt)
 
-#define FILE_NAME_MAXLEN       32
+#define STR_DATA_MAXLEN                32
+#define FILE_NAME_MAXLEN       (STR_DATA_MAXLEN * 2)
 #define DATA_PKT_SIZE          0x00040000      /* 256 KiB */
 #define FLASH_UNIT_SIZE                0x00100000      /* 1 MiB */
 
index 228e1cc..e77cc99 100644 (file)
@@ -258,7 +258,11 @@ static int thor_process_rqt_download(struct thor_context *tctx)
                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);
+               memcpy(f_name, rqt->str_data[0], STR_DATA_MAXLEN);
+
+               /* For longer filename than 32 */
+               if (rqt->str_data[0][STR_DATA_MAXLEN - 1] != '\0')
+                       memcpy(f_name + STR_DATA_MAXLEN, rqt->str_data[1], STR_DATA_MAXLEN);
 
                rsp.int_data[0] = DATA_PKT_SIZE;