[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241105072007.426782-1-danielyangkang@gmail.com>
Date: Mon, 4 Nov 2024 23:20:07 -0800
From: Daniel Yang <danielyangkang@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
linux-kernel@...r.kernel.org (open list:TRACING),
linux-trace-kernel@...r.kernel.org (open list:TRACING)
Cc: Daniel Yang <danielyangkang@...il.com>
Subject: [PATCH] set_cmdline: replace fragile/deprecated strncpy with strscpy
Kernel docs identify strncpy as being fragile and ambiguous. Replaced
strncpy with strscpy so dest str is null terminated and not padded.
Signed-off-by: Daniel Yang <danielyangkang@...il.com>
---
kernel/trace/trace_sched_switch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index 8a407adb0..573b5d8e8 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -187,7 +187,7 @@ static inline char *get_saved_cmdlines(int idx)
static inline void set_cmdline(int idx, const char *cmdline)
{
- strncpy(get_saved_cmdlines(idx), cmdline, TASK_COMM_LEN);
+ strscpy(get_saved_cmdlines(idx), cmdline, TASK_COMM_LEN);
}
static void free_saved_cmdlines_buffer(struct saved_cmdlines_buffer *s)
--
2.39.2
Powered by blists - more mailing lists