summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2019-12-30 13:53:27 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2019-12-30 15:44:35 +0900
commit4c2a98b6a0947397928e80245e2516ed5f987cbd (patch)
tree48ee44a065d208fde4855b1f88fbf4d5b9af0489
parent38cc9165138cedbfeb200783283bd6dabf94ef71 (diff)
downloadlinux-artik7-4c2a98b6a0947397928e80245e2516ed5f987cbd.tar.gz
linux-artik7-4c2a98b6a0947397928e80245e2516ed5f987cbd.tar.bz2
linux-artik7-4c2a98b6a0947397928e80245e2516ed5f987cbd.zip
net: wireless: sd8977: Fix stringop-overlfow build warnings
Not really need to check strlen() of source for strncpy() and it causes stringop-overlfow build warnings. If terminate character is required, fix the warnings by using strlcpy(). Otherwise, fix by using fixed number less than destination buffer size instead of source length for strncpy(). Change-Id: Ie1fcef44362c1ac6afa21d79b5eefaf5e7cdea75 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r--drivers/net/wireless/sd8977/wlan_src/mlinux/moal_main.c10
-rw-r--r--drivers/net/wireless/sd8977/wlan_src/mlinux/moal_priv.c4
-rw-r--r--drivers/net/wireless/sd8977/wlan_src/mlinux/moal_uap.c5
3 files changed, 8 insertions, 11 deletions
diff --git a/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_main.c b/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_main.c
index 923ee63471e2..e0d856e28031 100644
--- a/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_main.c
+++ b/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_main.c
@@ -2123,8 +2123,7 @@ woal_process_init_cfg(moal_handle *handle, t_u8 *data, t_size size)
goto done;
}
/* Copy value */
- strncpy(value, intf_s,
- MIN((MAX_PARAM_LEN - 1), strlen(intf_s)));
+ strlcpy(value, intf_s, sizeof(value));
if (MLAN_STATUS_SUCCESS !=
woal_process_regrdwr(handle, type, offset, value)) {
@@ -8139,13 +8138,12 @@ woal_request_country_power_table(moal_private *priv, char *country)
handle = priv->phandle;
/* Replace XX with ISO 3166-1 alpha-2 country code */
- strncpy(strstr(country_name, "XX"), country, strlen(country));
+ strncpy(strstr(country_name, "XX"), country, 2);
memset(file_path, 0, sizeof(file_path));
/* file_path should be Null terminated */
if (fw_name && (strlen(fw_name) < sizeof(file_path))) {
- strncpy(file_path, fw_name,
- MIN((sizeof(file_path) - 1), strlen(fw_name)));
+ strlcpy(file_path, fw_name, sizeof(file_path));
last_slash = strrchr(file_path, '/');
if (last_slash)
memset(last_slash + 1, 0,
@@ -8158,7 +8156,7 @@ woal_request_country_power_table(moal_private *priv, char *country)
}
country_txpwrlimit =
strncpy(file_path + strlen(file_path), country_name,
- strlen(country_name));
+ sizeof(file_path) - strlen(file_path) - 1);
if (MLAN_STATUS_SUCCESS !=
woal_set_user_init_data(handle, COUNTRY_POWER_TABLE,
diff --git a/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_priv.c b/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_priv.c
index 6705e117d4f0..c3a936fba311 100644
--- a/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_priv.c
+++ b/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_priv.c
@@ -3949,8 +3949,8 @@ woal_passphrase(moal_private *priv, struct iwreq *wrq)
break;
}
sec->param.passphrase.ssid.ssid_len = strlen(end);
- strncpy((char *)sec->param.passphrase.ssid.ssid, end,
- MIN((MLAN_MAX_SSID_LENGTH - 1), strlen(end)));
+ strlcpy((char *)sec->param.passphrase.ssid.ssid, end,
+ MLAN_MAX_SSID_LENGTH);
PRINTM(MINFO, "ssid=%s, len=%d\n",
sec->param.passphrase.ssid.ssid,
(int)sec->param.passphrase.ssid.ssid_len);
diff --git a/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_uap.c b/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_uap.c
index f3f3bc740d6b..335a983a338e 100644
--- a/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_uap.c
+++ b/drivers/net/wireless/sd8977/wlan_src/mlinux/moal_uap.c
@@ -3251,9 +3251,8 @@ woal_uap_ap_cfg_parse_data(mlan_uap_bss_param *ap_cfg, char *buf)
goto done;
}
ap_cfg->ssid.ssid_len = strlen(value);
- strncpy((char *)ap_cfg->ssid.ssid, value,
- MIN(MLAN_MAX_SSID_LENGTH - 1,
- strlen(value)));
+ strlcpy((char *)ap_cfg->ssid.ssid, value,
+ MLAN_MAX_SSID_LENGTH);
PRINTM(MINFO, "ssid=%s, len=%d\n",
ap_cfg->ssid.ssid,
(int)ap_cfg->ssid.ssid_len);