netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/sched: replace strncpy with strscpy
@ 2025-06-17 12:35 Pranav Tyagi
  2025-06-18 10:54 ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Pranav Tyagi @ 2025-06-17 12:35 UTC (permalink / raw)
  To: jhs, xiyou.wangcong, jiri
  Cc: davem, edumazet, kuba, pabeni, horms, netdev, linux-kernel, skhan,
	linux-kernel-mentees, Pranav Tyagi

Replace the deprecated strncpy() with strscpy() as the destination
buffer should be NUL-terminated and does not require any trailing
NUL-padding. Also, since NUL-termination is guaranteed,
use sizeof(conf.algo) in place of sizeof(conf.algo) - 1
as the size parameter.

Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
---
 net/sched/em_text.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/em_text.c b/net/sched/em_text.c
index 420c66203b17..1d0debfd62e5 100644
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -108,7 +108,7 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)
 	struct text_match *tm = EM_TEXT_PRIV(m);
 	struct tcf_em_text conf;
 
-	strncpy(conf.algo, tm->config->ops->name, sizeof(conf.algo) - 1);
+	strscpy(conf.algo, tm->config->ops->name, sizeof(conf.algo));
 	conf.from_offset = tm->from_offset;
 	conf.to_offset = tm->to_offset;
 	conf.from_layer = tm->from_layer;
-- 
2.49.0


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

end of thread, other threads:[~2025-06-18 14:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 12:35 [PATCH net-next] net/sched: replace strncpy with strscpy Pranav Tyagi
2025-06-18 10:54 ` Simon Horman
2025-06-18 14:23   ` Pranav Tyagi

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).