Skip to contentSkip to conversation

NFC: nxp-nci: Replace strcpy() with strscpy()

PATCH Applied [email protected] 3 participants 3 messages Mar 1 – Mar 4 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 NFC: nxp-nci: Replace strcpy() with strscpy()

From: Tomasz Unger <[email protected]>

Replace strcpy() with strscpy() which limits the copy to the size of the destination buffer. Since fw_info->name is an array, the two-argument variant of strscpy() is used - the compiler deduces the buffer size automatically.

This is a defensive cleanup replacing the deprecated strcpy() with the preferred strscpy().

---
Testing:
- checkpatch.pl: 0 errors, 0 warnings
- make M=drivers/nfc/nxp-nci/: compiled successfully, 0 errors, 0 warnings
- Module loaded successfully in QEMU (x86_64) with buildroot:
modprobe nxp-nci - no errors, confirmed via lsmod

 drivers/nfc/nxp-nci/firmware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/nxp-nci/firmware.c +1 -1
index 381b5bb75477..a9533977aff8 100644
@@ -211,7 +211,7 @@ int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name)
 		goto fw_download_exit;
 	}
 
-	strcpy(fw_info->name, firmware_name);
+	strscpy(fw_info->name, firmware_name);
 
 	r = request_firmware(&fw_info->fw, firmware_name,
 			     ndev->nfc_dev->dev.parent);
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#2 lore raw
Quoted 10 lines · On Sun, Mar 01, 2026 at 02:56:33PM +0100, [email protected] wrote:

From: Tomasz Unger <[email protected]>

Replace strcpy() with strscpy() which limits the copy to the size of the destination buffer. Since fw_info->name is an array, the two-argument variant of strscpy() is used - the compiler deduces the buffer size automatically.

This is a defensive cleanup replacing the deprecated strcpy() with the preferred strscpy().

Quoted 7 lines

---
Testing:
- checkpatch.pl: 0 errors, 0 warnings
- make M=drivers/nfc/nxp-nci/: compiled successfully, 0 errors, 0 warnings
- Module loaded successfully in QEMU (x86_64) with buildroot:
modprobe nxp-nci - no errors, confirmed via lsmod

#3 lore raw
In reply to [email protected]
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Sun, 1 Mar 2026 14:56:33 +0100 you wrote:

From: Tomasz Unger <[email protected]>

Replace strcpy() with strscpy() which limits the copy to the size of the destination buffer. Since fw_info->name is an array, the two-argument variant of strscpy() is used - the compiler deduces the buffer size automatically.

[...]

Here is the summary with links:
- [net-next,v1] NFC: nxp-nci: Replace strcpy() with strscpy()

    https://git.kernel.org/netdev/net-next/c/66e807f96f4e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html