Skip to contentSkip to conversation

tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf

PATCH RESEND New Devaansh Kumar 1 participant 1 message May 7, 2025 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v5 1/1 tracing: Replace deprecated strncpy() with strscpy() for stack_trace_filter_buf

strncpy() is deprecated for NUL-terminated destination buffers and must be replaced by strscpy().

See issue: https://github.com/KSPP/linux/issues/90

---

Changes since v4:
- Removed unnecessary sizeof(stack_trace_filter_buf) in strscpy

Changes since v3:
- Refactored code to compare length with str_has_prefix in a single line

Changes since v2;
- Removed unnecessary string.h header file inclusion

Changes since v1:
- Moved from memcpy() to strscpy()

 kernel/trace/trace_stack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_stack.c +1 -1
index 14c6f272c4d8..4c349db381cb 100644
@@ -542,7 +542,7 @@ static __init int enable_stacktrace(char *str)
 	int len;
 
 	if ((len = str_has_prefix(str, "_filter=")))
-		strncpy(stack_trace_filter_buf, str + len, COMMAND_LINE_SIZE);
+		strscpy(stack_trace_filter_buf, str + len);
 
 	stack_tracer_enabled = 1;
 	return 1;
Signature · 1 line
2.49.0