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.

tipc: Removing deprecated strncpy()

This patch suggests the replacement of strncpy with strscpy
as per Documentation/process/deprecated.
The strncpy() fails to guarantee NULL termination,
The function adds zero pads which isn't really convenient for short strings
as it may cause performance issues.

strscpy() is a preferred replacement because
it overcomes the limitations of strncpy mentioned above.

Compile Tested

Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>
Tested-by: Tung Nguyen <tung.quang.nguyen@est.tech>
Link: https://patch.msgid.link/20250411085010.6249-1-kevinpaul468@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Kevin Paul Reddy Janagari and committed by
Paolo Abeni
8c9b406f 4c2e0b00

+2 -2
+1 -1
net/tipc/link.c
··· 2228 2228 break; 2229 2229 if (msg_data_sz(hdr) < TIPC_MAX_IF_NAME) 2230 2230 break; 2231 - strncpy(if_name, data, TIPC_MAX_IF_NAME); 2231 + strscpy(if_name, data, TIPC_MAX_IF_NAME); 2232 2232 2233 2233 /* Update own tolerance if peer indicates a non-zero value */ 2234 2234 if (tipc_in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) {
+1 -1
net/tipc/node.c
··· 1581 1581 tipc_node_read_lock(node); 1582 1582 link = node->links[bearer_id].link; 1583 1583 if (link) { 1584 - strncpy(linkname, tipc_link_name(link), len); 1584 + strscpy(linkname, tipc_link_name(link), len); 1585 1585 err = 0; 1586 1586 } 1587 1587 tipc_node_read_unlock(node);