drivers/nfc/nfcmrvl/fw_dnld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Tomasz Unger <tomasz.unger@yahoo.pl>
Replace strcpy() with strscpy() which limits the copy to the size of
the destination buffer. Since fw_dnld->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/nfcmrvl/: compiled successfully, 0 errors, 0 warnings
- Module loaded successfully in QEMU (x86_64) with buildroot:
modprobe nfcmrvl - no errors, confirmed via lsmod
drivers/nfc/nfcmrvl/fw_dnld.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/nfcmrvl/fw_dnld.c b/drivers/nfc/nfcmrvl/fw_dnld.c
index a9b03dcc4100..2b8f401d8fd7 100644
--- a/drivers/nfc/nfcmrvl/fw_dnld.c
+++ b/drivers/nfc/nfcmrvl/fw_dnld.c
@@ -492,7 +492,7 @@ int nfcmrvl_fw_dnld_start(struct nci_dev *ndev, const char *firmware_name)
if (!firmware_name || !firmware_name[0])
return -EINVAL;
- strcpy(fw_dnld->name, firmware_name);
+ strscpy(fw_dnld->name, firmware_name);
/*
* Retrieve FW binary file and parse it to initialize FW download
--
2.53.0
On Sun, Mar 01, 2026 at 03:43:45PM +0100, 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_dnld->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> Reviewed-by: Simon Horman <horms@kernel.org>
© 2016 - 2026 Red Hat, Inc.