diff options
author | Justin Stitt <[email protected]> | 2024-10-14 14:13:14 -0700 |
---|---|---|
committer | Steven Rostedt (Google) <[email protected]> | 2024-10-30 19:41:08 -0400 |
commit | 77a1326f64c3245ae9d2f9297abec5c8a0f11f58 (patch) | |
tree | e6261c56467b2d66965ccee8a33573b13b75b526 /kernel/trace/trace_output.c | |
parent | 2c33155ef678033b8a3105b824cdef930f05b47d (diff) |
tracing: Replace multiple deprecated strncpy with memcpy
strncpy() is deprecated for use on NUL-terminated destination strings [1] and
as such we should prefer more robust and less ambiguous string interfaces.
String copy operations involving manual pointer offset and length
calculations followed by explicit NUL-byte assignments are best changed
to either strscpy or memcpy.
strscpy is not a drop-in replacement as @len would need a one subtracted
from it to avoid truncating the source string.
To not sabotage readability of the current code, use memcpy (retaining
the manual NUL assignment) as this unambiguously describes the desired
behavior.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://github.com/KSPP/linux/issues/90 [2]
Cc: Masami Hiramatsu <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/20241014-strncpy-kernel-trace-trace_events_filter-c-v2-1-d821e81e371e@google.com
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Justin Stitt <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
Diffstat (limited to 'kernel/trace/trace_output.c')
0 files changed, 0 insertions, 0 deletions