Skip to content

Commit 8c9b406

Browse files
kevinpaul468Paolo Abeni
authored andcommitted
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 <[email protected]> Reviewed-by: Tung Nguyen <[email protected]> Tested-by: Tung Nguyen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4c2e0b0 commit 8c9b406

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

net/tipc/link.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
22282228
break;
22292229
if (msg_data_sz(hdr) < TIPC_MAX_IF_NAME)
22302230
break;
2231-
strncpy(if_name, data, TIPC_MAX_IF_NAME);
2231+
strscpy(if_name, data, TIPC_MAX_IF_NAME);
22322232

22332233
/* Update own tolerance if peer indicates a non-zero value */
22342234
if (tipc_in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) {

net/tipc/node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr,
15811581
tipc_node_read_lock(node);
15821582
link = node->links[bearer_id].link;
15831583
if (link) {
1584-
strncpy(linkname, tipc_link_name(link), len);
1584+
strscpy(linkname, tipc_link_name(link), len);
15851585
err = 0;
15861586
}
15871587
tipc_node_read_unlock(node);

0 commit comments

Comments
 (0)