Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

NFC: pn544: i2c: Replace strcpy() with strscpy()

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

This is a defensive cleanup. As pointed out by Jakub Kicinski
<kuba@kernel.org>, firmware_name is already bounded to
NFC_FIRMWARE_NAME_MAXSIZE via nla_strscpy() in net/nfc/netlink.c
before reaching this driver, so no actual buffer overflow is possible.

Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260301121254.174354-1-tomasz.unger@yahoo.pl
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Tomasz Unger and committed by
Jakub Kicinski
e63f5918 ed0abfe9

+1 -1
+1 -1
drivers/nfc/pn544/i2c.c
··· 526 526 527 527 pr_info("Starting Firmware Download (%s)\n", firmware_name); 528 528 529 - strcpy(phy->firmware_name, firmware_name); 529 + strscpy(phy->firmware_name, firmware_name); 530 530 531 531 phy->hw_variant = hw_variant; 532 532 phy->fw_work_state = FW_WORK_STATE_START;