[PATCH net-next v1] NFC: s3fwrn5: Replace strcpy() with strscpy()

tomasz.unger@yahoo.pl posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
drivers/nfc/s3fwrn5/firmware.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH net-next v1] NFC: s3fwrn5: Replace strcpy() with strscpy()
Posted by tomasz.unger@yahoo.pl 1 month, 2 weeks ago
From: Tomasz Unger <tomasz.unger@yahoo.pl>

Replace strcpy() with strscpy() which limits the copy to the size of
the destination buffer. Since fw_info->fw_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().

Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
---
Testing:
- checkpatch.pl: 0 errors, 0 warnings
- make M=drivers/nfc/s3fwrn5/: compiled successfully, 0 errors, 0 warnings
- Module loaded successfully in QEMU (x86_64) with buildroot:
  modprobe s3fwrn5 - no errors, confirmed via lsmod

 drivers/nfc/s3fwrn5/firmware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
index 64d61b2a715a..9145deec7f6c 100644
--- a/drivers/nfc/s3fwrn5/firmware.c
+++ b/drivers/nfc/s3fwrn5/firmware.c
@@ -454,7 +454,7 @@ void s3fwrn5_fw_init(struct s3fwrn5_fw_info *fw_info, const char *fw_name)
 	fw_info->parity = 0x00;
 	fw_info->rsp = NULL;
 	fw_info->fw.fw = NULL;
-	strcpy(fw_info->fw_name, fw_name);
+	strscpy(fw_info->fw_name, fw_name);
 	init_completion(&fw_info->completion);
 }
 
-- 
2.53.0
Re: [PATCH net-next v1] NFC: s3fwrn5: Replace strcpy() with strscpy()
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On 01/03/2026 15:32, tomasz.unger@yahoo.pl wrote:
> From: Tomasz Unger <tomasz.unger@yahoo.pl>
> 
> Replace strcpy() with strscpy() which limits the copy to the size of
> the destination buffer. Since fw_info->fw_name is an array, the

"an array with a fixed, declared size"

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

See similar comment here:
https://lore.kernel.org/all/8e68e02a-2c58-485c-a13e-a4b52616e63e@kernel.org/


Best regards,
Krzysztof