From 7eeddceddfef485cea7af6a8b0310f0ae60fdc81 Mon Sep 17 00:00:00 2001 From: Avinash Pandey Date: Tue, 20 Feb 2018 12:10:17 +0530 Subject: [PATCH] Sysupgrade: Fixing kw issues in string functions. This change replaces banned function namely, strncat and strncpy to strlcat and strlcpy respectively. Change-Id: Ic02f59b29d1e58a937670f5e53dd1199cb55e53e Signed-off-by: Avinash Pandey --- tools/sysupgrade.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/sysupgrade.c b/tools/sysupgrade.c index ae26c232df..0294278b8c 100644 --- a/tools/sysupgrade.c +++ b/tools/sysupgrade.c @@ -202,14 +202,14 @@ int get_sections(void) for (i = 0, sec = §ions[0]; i < NO_OF_SECTIONS; i++, sec++) { if (strstr(file->d_name, sec->type)) { if (sec->pre_op) { - strncat(sec->tmp_file, file->d_name, + strlcat(sec->tmp_file, file->d_name, sizeof(sec->tmp_file)); if (!sec->pre_op(sec)) { printf("Error extracting kernel from ubi\n"); return 0; } } else { - strncat(sec->file, file->d_name, + strlcat(sec->file, file->d_name, sizeof(sec->file)); } if (!check_mbn_elf(&sec)) { @@ -247,7 +247,7 @@ int load_sections(void) for (i = 0, sec = §ions[0]; i < NO_OF_SECTIONS; i++, sec++) { if (strstr(file->d_name, sec->type)) { if (sec->pre_op) { - strncat(sec->tmp_file, file->d_name, + strlcat(sec->tmp_file, file->d_name, sizeof(sec->tmp_file)); if (!sec->pre_op(sec)) { printf("Error extracting %s from ubi\n", @@ -256,7 +256,7 @@ int load_sections(void) return 0; } } else { - strncat(sec->file, file->d_name, + strlcat(sec->file, file->d_name, sizeof(sec->file)); } sec->is_present = PRESENT; @@ -403,7 +403,7 @@ char *find_value(char *buffer, char *search, int size) for (i = 0; i < CERT_SIZE; i++) { for (j = 0; search[j] && (buffer[i + j] == search[j]); j++); if (search[j] == '\0') { - strncpy(value, &buffer[i - size], size); + strlcpy(value, &buffer[i - size], size); value[size - 1] = '\0'; return value; } @@ -1219,7 +1219,7 @@ int generate_hash(char *cert, char *sw_file, char *hw_file) free(oem_model_id_str); return 0; } - strncpy(sw_file, tmp, 32); + strlcpy(sw_file, tmp, 32); generate_hwid_opad(hw_id_str, oem_id_str, oem_model_id_str, &hwid_xor_opad); tmp = create_xor_ipad_opad(f_hw_xor, &hwid_xor_opad); @@ -1230,7 +1230,7 @@ int generate_hash(char *cert, char *sw_file, char *hw_file) free(oem_model_id_str); return 0; } - strncpy(hw_file, tmp, 32); + strlcpy(hw_file, tmp, 32); free(sw_id_str); free(hw_id_str);