From: jino.cho Date: Wed, 11 Jan 2017 02:38:42 +0000 (+0900) Subject: f_thor: fixes 32byte limit of a file name length X-Git-Tag: submit/tizen/20190213.074817~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f62ffd18cd0ea9ef643883c348da19b293dfece;p=profile%2Fcommon%2Fplatform%2Fkernel%2Fu-boot-artik7.git f_thor: fixes 32byte limit of a file name length 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 --- diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c index a60e9487e7..74443fe767 100644 --- a/drivers/usb/gadget/f_thor.c +++ b/drivers/usb/gadget/f_thor.c @@ -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); diff --git a/drivers/usb/gadget/f_thor.h b/drivers/usb/gadget/f_thor.h index 83412851dd..8b7e6c52bf 100644 --- a/drivers/usb/gadget/f_thor.h +++ b/drivers/usb/gadget/f_thor.h @@ -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