f_thor: fixes 32byte limit of a file name length
authorjino.cho <jino.cho@samsung.com>
Wed, 11 Jan 2017 02:38:42 +0000 (11:38 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 21 Jan 2019 05:39:52 +0000 (14:39 +0900)
The str_data, a member of rqt_box structure, have 5 arrays of 32 byte in
length. Currently, a file name is limited to 32 bytes because the code
considers using just one array of the str_data for a file name. But, the
lthor can send a file name that is grater than 32 bytes. Whether it is a bug
or not, we have to transfer a long name file in this project. So, this
commit allows to send a file with a file name length of 64 - 1 bytes
temporarily. Since the rqt_box structure is __packed type, str_data has
contiguous memory and does not cause memory problems.

Change-Id: Id7380ffc5bfb398cf4049e584561943a0d1349e7
Signed-off-by: jino.cho <jino.cho@samsung.com>
drivers/usb/gadget/f_thor.c
drivers/usb/gadget/f_thor.h

index a60e9487e7746d62a98d8aa04db11a335aeb9f9c..74443fe767e4d4e2b122fa887899da9ef5b5bd1d 100644 (file)
@@ -276,7 +276,7 @@ static long long int process_rqt_download(const struct rqt_box *rqt)
                }
 
                thor_file_size = rqt->int_data[1];
-               memcpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE);
+               strncpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE - 1);
 
                debug("INFO: name(%s, %d), size(%llu), type(%d)\n",
                      f_name, 0, thor_file_size, file_type);
index 83412851dd17f6100f7c2eda67b0e30e8b69958d..8b7e6c52bf28be383a5aebb719dc0ee806237e35 100644 (file)
@@ -118,7 +118,7 @@ struct f_thor {
        struct thor_dev *dev;
 };
 
-#define F_NAME_BUF_SIZE 32
+#define F_NAME_BUF_SIZE 64
 #define THOR_PACKET_SIZE SZ_1M      /* 1 MiB */
 #define THOR_STORE_UNIT_SIZE SZ_32M /* 32 MiB */
 #ifdef CONFIG_THOR_RESET_OFF