Skip to contentSkip to conversation

net/sched: replace strncpy with strscpy

PATCH Applied Pranav Tyagi 3 participants 3 messages Jun 20, 2025 – Jun 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/sched: replace strncpy with strscpy

Replace the deprecated strncpy() with the two-argument version of strscpy() as the destination is an array
and buffer should be NUL-terminated.

---
 net/sched/em_text.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/em_text.c +1 -1
index 420c66203b17..6b3d0af72c39 100644
@@ -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;
Signature · 1 line
2.49.0
#2 lore raw
In reply to Pranav Tyagi
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 20 Jun 2025 16:06:53 +0530 you wrote:

Replace the deprecated strncpy() with the two-argument version of strscpy() as the destination is an array
and buffer should be NUL-terminated.

---
 net/sched/em_text.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [v2,net-next] net/sched: replace strncpy with strscpy

    https://git.kernel.org/netdev/net-next/c/b04202d6065c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html