netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: rds: Replace strncpy with strscpy in connection setup
@ 2025-04-23 15:37 Shankari02
  2025-04-25  1:36 ` Jakub Kicinski
  0 siblings, 1 reply; 12+ messages in thread
From: Shankari02 @ 2025-04-23 15:37 UTC (permalink / raw)
  To: netdev
  Cc: allison.henderson, davem, edumazet, kuba, pabeni, horms, skhan,
	Shankari02

This patch replaces strncpy() with strscpy(), which is the
preferred, safer alternative. strscpy() guarantees null-termination
as long as the destination buffer is non-zero in size, and also
provides a return value that can be used to detect truncation.

This change is made in accordance with the Linux kernel
documentation which marks strncpy() as deprecated for bounded
string copying:

  https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy

Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
---
 net/rds/connection.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rds/connection.c b/net/rds/connection.c
index c749c5525b40..fb2f14a1279a 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -749,7 +749,7 @@ static int rds_conn_info_visitor(struct rds_conn_path *cp, void *buffer)
 	cinfo->laddr = conn->c_laddr.s6_addr32[3];
 	cinfo->faddr = conn->c_faddr.s6_addr32[3];
 	cinfo->tos = conn->c_tos;
-	strncpy(cinfo->transport, conn->c_trans->t_name,
+	strscpy(cinfo->transport, conn->c_trans->t_name,
 		sizeof(cinfo->transport));
 	cinfo->flags = 0;
 
@@ -775,7 +775,7 @@ static int rds6_conn_info_visitor(struct rds_conn_path *cp, void *buffer)
 	cinfo6->next_rx_seq = cp->cp_next_rx_seq;
 	cinfo6->laddr = conn->c_laddr;
 	cinfo6->faddr = conn->c_faddr;
-	strncpy(cinfo6->transport, conn->c_trans->t_name,
+	strscpy(cinfo6->transport, conn->c_trans->t_name,
 		sizeof(cinfo6->transport));
 	cinfo6->flags = 0;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-05-21 17:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 15:37 [PATCH] net: rds: Replace strncpy with strscpy in connection setup Shankari02
2025-04-25  1:36 ` Jakub Kicinski
2025-04-26 19:21   ` [PATCH v2] " Shankari Anand
2025-04-26 19:26     ` Shankari
2025-04-30 18:16       ` Simon Horman
2025-05-21  5:52         ` [PATCH v3] " Shankari Anand
2025-05-21  5:54         ` Shankari Anand
2025-05-21 12:58           ` [PATCH v4] " Shankari Anand
2025-05-21 17:21             ` Allison Henderson
2025-05-21  6:05         ` [PATCH v3] " Shankari Anand
2025-04-28 23:25     ` [PATCH v2] " Allison Henderson
2025-04-29 18:09     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).