ACPI: sysfs: use strscpy() instead of strcpy()

strcpy() is deprecated in the kernel, so use strscpy() with the
compile-time known size of the trace_method_name buffer instead
of it.

The existing length check already rejects overlong input, so
the behavior is unchanged.

Signed-off-by: Ruslan Vagner <rusya92266@gmail.com>
[ rjw: Changelog edits ]
Link: https://patch.msgid.link/CAF9RqJ4ip_egVwRKnwn3=X-Qxuwz0u_9pNrgfujBw8RSf2DTPQ@mail.gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Ruslan Vagner 2026-09-15 05:56:13 -07:00 committed by Rafael J. Wysocki
parent fd73f4a665
commit 68a385dbe0

View File

@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <linux/kstrtox.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include "internal.h"
@ -181,10 +182,10 @@ static int param_set_trace_method_name(const char *val,
/* This is a hack. We can't kmalloc in early boot. */
if (is_abs_path)
strcpy(trace_method_name, val);
strscpy(trace_method_name, val, sizeof(trace_method_name));
else {
trace_method_name[0] = '\\';
strcpy(trace_method_name+1, val);
strscpy(trace_method_name + 1, val, sizeof(trace_method_name) - 1);
}
/* Restore the original tracer state */