[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190823074708.20081-1-xulin.sun@windriver.com>
Date: Fri, 23 Aug 2019 15:47:08 +0800
From: Xulin Sun <xulin.sun@...driver.com>
To: <kvalo@...eaurora.org>
CC: <stefan.wahren@...e.com>, <xulin.sun@...driver.com>,
<linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
<brcm80211-dev-list@...ress.com>,
<brcm80211-dev-list.pdl@...adcom.com>,
<linux-wireless@...r.kernel.org>, <arend.vanspriel@...adcom.com>,
<franky.lin@...adcom.com>, <hante.meuleman@...adcom.com>,
<chi-hsien.lin@...ress.com>, <wright.feng@...ress.com>,
<davem@...emloft.net>, <stanley.hsu@...ress.com>
Subject: [PATCH] brcmfmac: replace strncpy() by strscpy()
The strncpy() may truncate the copied string,
replace it by the safer strscpy().
To avoid below compile warning with gcc 8.2:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:In function 'brcmf_vndr_ie':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:4227:2:
warning: 'strncpy' output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Xulin Sun <xulin.sun@...driver.com>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index b6d0df354b36..7ad60374fa96 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4226,9 +4226,7 @@ brcmf_parse_vndr_ies(const u8 *vndr_ie_buf, u32 vndr_ie_len,
static u32
brcmf_vndr_ie(u8 *iebuf, s32 pktflag, u8 *ie_ptr, u32 ie_len, s8 *add_del_cmd)
{
-
- strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1);
- iebuf[VNDR_IE_CMD_LEN - 1] = '\0';
+ strscpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN);
put_unaligned_le32(1, &iebuf[VNDR_IE_COUNT_OFFSET]);
--
2.17.1
Powered by blists - more mailing lists