diff options
author | Yunmi Ha <yunmi.ha@samsung.com> | 2019-08-27 16:17:41 +0900 |
---|---|---|
committer | Yunmi Ha <yunmi.ha@samsung.com> | 2019-08-27 17:14:17 +0900 |
commit | b0dc5013c452a6ae14a44622df552b9e1740bea8 (patch) | |
tree | 68d8db29cc284dfbd8bbf5d0e66971a4212345ef | |
parent | 9dc6c0123c05c60cdd86c115331ea1137b051f37 (diff) | |
download | device-tm1-b0dc5013c452a6ae14a44622df552b9e1740bea8.tar.gz device-tm1-b0dc5013c452a6ae14a44622df552b9e1740bea8.tar.bz2 device-tm1-b0dc5013c452a6ae14a44622df552b9e1740bea8.zip |
Fix svace issue
- change strcpy function to strncpy
Change-Id: Icadf6b2717d1093d8514b16e01fd03ceb44ea728
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rw-r--r-- | hw/board/board.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/board/board.c b/hw/board/board.c index d8bb35a..2cbc583 100644 --- a/hw/board/board.c +++ b/hw/board/board.c @@ -46,6 +46,7 @@ static int get_serialno_from_dat(void) { FILE *fp; char buffer[DATA_BUFF_MAX], *p, *q; + int len; fp = fopen(SERIAL_PATH_NAME, "r"); if (!fp) { @@ -62,7 +63,9 @@ static int get_serialno_from_dat(void) q = strchrnul(p, '\n'); *q = '\0'; - strcpy(info.serial, p); + len = strlen(p) > DATA_BUFF_MAX-1 ? DATA_BUFF_MAX-1 : strlen(p); + strncpy(info.serial, p, len); + info.serial[len] = '\0'; info.serial_len = strlen(p); fclose(fp); @@ -73,6 +76,7 @@ static int get_serialno_from_cpuinfo(void) { FILE *fp; char line[LINE_LEN], *p, *q; + int len; fp = fopen(CPUINFO_PATH, "r"); if (!fp) { @@ -97,7 +101,9 @@ static int get_serialno_from_cpuinfo(void) q = strchrnul(p, '\n'); *q = '\0'; - strcpy(info.serial, p); + len = strlen(p) > DATA_BUFF_MAX-1 ? DATA_BUFF_MAX-1 : strlen(p); + strncpy(info.serial, p, len); + info.serial[len] = '\0'; info.serial_len = strlen(p); fclose(fp); |