355-v5.4-brcmfmac-replace-strncpy-by-strscpy.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 5f42b382ead278c1f6c3854765c97eb20491aa2a Mon Sep 17 00:00:00 2001
  2. From: Xulin Sun <xulin.sun@windriver.com>
  3. Date: Fri, 23 Aug 2019 15:47:08 +0800
  4. Subject: [PATCH] brcmfmac: replace strncpy() by strscpy()
  5. The strncpy() may truncate the copied string,
  6. replace it by the safer strscpy().
  7. To avoid below compile warning with gcc 8.2:
  8. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:In function 'brcmf_vndr_ie':
  9. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:4227:2:
  10. warning: 'strncpy' output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
  11. strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1);
  12. ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
  14. Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  15. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  16. ---
  17. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 4 +---
  18. 1 file changed, 1 insertion(+), 3 deletions(-)
  19. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  20. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  21. @@ -4280,9 +4280,7 @@ next:
  22. static u32
  23. brcmf_vndr_ie(u8 *iebuf, s32 pktflag, u8 *ie_ptr, u32 ie_len, s8 *add_del_cmd)
  24. {
  25. -
  26. - strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1);
  27. - iebuf[VNDR_IE_CMD_LEN - 1] = '\0';
  28. + strscpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN);
  29. put_unaligned_le32(1, &iebuf[VNDR_IE_COUNT_OFFSET]);