]> www.infradead.org Git - users/hch/misc.git/commitdiff
net/smc: Replace use of strncpy on NUL-terminated string with strscpy
authorJames Flowers <bold.zone2373@fastmail.com>
Mon, 1 Sep 2025 03:04:59 +0000 (20:04 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 2 Sep 2025 21:05:49 +0000 (14:05 -0700)
strncpy is deprecated for use on NUL-terminated strings, as indicated in
Documentation/process/deprecated.rst. strncpy NUL-pads the destination
buffer and doesn't guarantee the destination buffer will be NUL
terminated.

Signed-off-by: James Flowers <bold.zone2373@fastmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Dust Li <dust.li@linux.alibaba.com>
Reviewed-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
Link: https://patch.msgid.link/20250901030512.80099-1-bold.zone2373@fastmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/smc/smc_pnet.c

index 76ad29e31d605d0091741a5500e0ab0abea06a7c..b90337f86e8368fa60e2eb6e19560ed7fe702580 100644 (file)
@@ -450,7 +450,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,
                return -ENOMEM;
        new_pe->type = SMC_PNET_IB;
        memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN);
-       strncpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX);
+       strscpy(new_pe->ib_name, ib_name);
        new_pe->ib_port = ib_port;
 
        new_ibdev = true;