lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250414192532.GX395307@horms.kernel.org>
Date: Mon, 14 Apr 2025 20:25:32 +0100
From: Simon Horman <horms@...nel.org>
To: Tung Quang Nguyen <tung.quang.nguyen@....tech>
Cc: Kevin Paul Reddy Janagari <kevinpaul468@...il.com>, jmaloy@...hat.com,
	davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, netdev@...r.kernel.org,
	tipc-discussion@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] tipc: Removing deprecated strncpy()

On Fri, Apr 11, 2025 at 10:46:32AM +0000, Tung Quang Nguyen wrote:
> >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@...il.com>
> >---
> > net/tipc/link.c | 2 +-
> > net/tipc/node.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> >diff --git a/net/tipc/link.c b/net/tipc/link.c index 18be6ff4c3db..3ee44d731700
> >100644
> >--- a/net/tipc/link.c
> >+++ b/net/tipc/link.c
> >@@ -2228,7 +2228,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct
> >sk_buff *skb,
> > 			break;
> > 		if (msg_data_sz(hdr) < TIPC_MAX_IF_NAME)
> > 			break;
> >-		strncpy(if_name, data, TIPC_MAX_IF_NAME);
> >+		strscpy(if_name, data, TIPC_MAX_IF_NAME);
> >
> > 		/* Update own tolerance if peer indicates a non-zero value */
> > 		if (tipc_in_range(peers_tol, TIPC_MIN_LINK_TOL,
> >TIPC_MAX_LINK_TOL)) { diff --git a/net/tipc/node.c b/net/tipc/node.c index
> >ccf5e427f43e..cb43f2016a70 100644
> >--- a/net/tipc/node.c
> >+++ b/net/tipc/node.c
> >@@ -1581,7 +1581,7 @@ int tipc_node_get_linkname(struct net *net, u32
> >bearer_id, u32 addr,
> > 	tipc_node_read_lock(node);
> > 	link = node->links[bearer_id].link;
> > 	if (link) {
> >-		strncpy(linkname, tipc_link_name(link), len);
> >+		strscpy(linkname, tipc_link_name(link), len);
> > 		err = 0;
> > 	}
> > 	tipc_node_read_unlock(node);
> >--
> >2.39.5
> Reviewed-and-tested-by: Tung Nguyen <tung.quang.nguyen@....tech>

Hi Tung,

Thanks for reviewing these patches,
but I think it's best not to use non-standard tags.

Reviewed-by: ...
Tested-by: ...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ