[PATCH v2 net-next] net/sched: replace strncpy with strscpy

Pranav Tyagi posted 1 patch 3 months, 2 weeks ago
net/sched/em_text.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2 net-next] net/sched: replace strncpy with strscpy
Posted by Pranav Tyagi 3 months, 2 weeks ago
Replace the deprecated strncpy() with the two-argument version of
strscpy() as the destination is an array
and buffer should be NUL-terminated.

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..6b3d0af72c39 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);
 	conf.from_offset = tm->from_offset;
 	conf.to_offset = tm->to_offset;
 	conf.from_layer = tm->from_layer;
-- 
2.49.0
Re: [PATCH v2 net-next] net/sched: replace strncpy with strscpy
Posted by Simon Horman 3 months, 2 weeks ago
On Fri, Jun 20, 2025 at 04:06:53PM +0530, Pranav Tyagi wrote:
> Replace the deprecated strncpy() with the two-argument version of
> strscpy() as the destination is an array
> and buffer should be NUL-terminated.
> 
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>