mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 15:51:30 -05:00
tracing: Replace strncpy with memcpy for fixed-length substring copy
checkpatch.pl reports the following warning: WARNING: Prefer strscpy, strscpy_pad, or __nonstring over strncpy (see: https://github.com/KSPP/linux/issues/90) In synth_field_string_size(), replace strncpy() with memcpy() to copy 'len' characters from 'start' to 'buf'. The code manually adds a NUL terminator after the copy, making memcpy safe here. Link: https://lore.kernel.org/20250325181232.38284-1-siddarthsgml@gmail.com Signed-off-by: Siddarth G <siddarthsgml@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt (Google)
parent
4d38328eb4
commit
e0344f9564
@@ -207,7 +207,7 @@ static int synth_field_string_size(char *type)
|
||||
if (len == 0)
|
||||
return 0; /* variable-length string */
|
||||
|
||||
strncpy(buf, start, len);
|
||||
memcpy(buf, start, len);
|
||||
buf[len] = '\0';
|
||||
|
||||
err = kstrtouint(buf, 0, &size);
|
||||
|
||||
Reference in New Issue
Block a user