From f32527fbe7155d61fb61c686ba941edfc15a934a Mon Sep 17 00:00:00 2001 From: Triveni Danda Date: Fri, 23 Feb 2024 15:52:30 +0530 Subject: [PATCH] Changed strcpy to strncpy. Signed-off-by: Triveni Danda --- zephyr/src/indigo_api_callback_dut.c | 4 ++-- zephyr/src/utils.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zephyr/src/indigo_api_callback_dut.c b/zephyr/src/indigo_api_callback_dut.c index bd0fe9a..f323518 100644 --- a/zephyr/src/indigo_api_callback_dut.c +++ b/zephyr/src/indigo_api_callback_dut.c @@ -1481,7 +1481,7 @@ static int set_ap_parameter_handler(struct packet_wrapper *req, struct packet_wr tlv = find_wrapper_tlv_by_id(req, TLV_GAS_COMEBACK_DELAY); } if (tlv && find_tlv_config_name(tlv->id) != NULL) { - strcpy(param_name, find_tlv_config_name(tlv->id)); + strncpy(param_name, find_tlv_config_name(tlv->id), sizeof(param_name)); memcpy(param_value, tlv->value, sizeof(param_value)); } else { status = TLV_VALUE_STATUS_NOT_OK; @@ -1798,7 +1798,7 @@ static int set_sta_parameter_handler(struct packet_wrapper *req, struct packet_w memset(param_name, 0, sizeof(param_name)); memset(param_value, 0, sizeof(param_value)); tlv = req->tlv[i]; - strcpy(param_name, find_tlv_config_name(tlv->id)); + strncpy(param_name, find_tlv_config_name(tlv->id), sizeof(param_name)); memcpy(param_value, tlv->value, sizeof(param_value)); /* Assemble wpa_supplicant command */ diff --git a/zephyr/src/utils.c b/zephyr/src/utils.c index b886afc..d658cf2 100644 --- a/zephyr/src/utils.c +++ b/zephyr/src/utils.c @@ -893,9 +893,9 @@ int set_hapd_exec_file(char* path) { char *ptr = indigo_strrstr(path, "/"); if (ptr) { - strcpy(hapd_exec_file, ptr+1); + strncpy(hapd_exec_file, ptr+1, sizeof(hapd_exec_file)); } else { - strcpy(hapd_exec_file, path); + strncpy(hapd_exec_file, path, sizeof(hapd_exec_file)); } return 0; } @@ -978,9 +978,9 @@ char* get_wpas_exec_file() { int set_wpas_exec_file(char* path) { char *ptr = indigo_strrstr(path, "/"); if (ptr) { - strcpy(wpas_exec_file, ptr+1); + strncpy(wpas_exec_file, ptr+1, sizeof(wpas_exec_file)); } else { - strcpy(wpas_exec_file, path); + strncpy(wpas_exec_file, path, sizeof(wpas_exec_file)); } return 0; } @@ -1052,7 +1052,7 @@ int add_wireless_interface_info(int band, int bssid, char *name) { interfaces[interface_count].band = band; interfaces[interface_count].bssid = -1; interfaces[interface_count].identifier = UNUSED_IDENTIFIER; - strcpy(interfaces[interface_count++].ifname, name); + strncpy(interfaces[interface_count++].ifname, name, sizeof(interfaces[interface_count].ifname)); return 0; }