[PATCH net-next] net/sched: replace strncpy with strscpy
From: Pranav Tyagi
Date: Tue Jun 17 2025 - 08:35:57 EST
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@xxxxxxxxx>
---
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