Fix unterminated buffer if the length of str exceeds MAX_TRACER_SIZE
PATCH 1/1 Fix unterminated buffer if the length of str exceeds MAX_TRACER_SIZE
strncpy() doesn't always zero terminate the string.
Detected by "cppcheck"
Signed-off-by Thomas Jarosch <[email protected]>
--- kernel/trace/trace.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/trace/trace.c +2 -1
@@ -126,7 +126,8 @@ static char *default_bootup_tracer;static int __init set_cmdline_ftrace (char *str) { -strncpy (bootup_tracer_buf, str,MAX_TRACER_SIZE ); +strncpy (bootup_tracer_buf, str,MAX_TRACER_SIZE -1 ); + bootup_tracer_buf[MAX_TRACER_SIZE -1 ] ='\0' ; default_bootup_tracer = bootup_tracer_buf;/* We are using ftrace early, expand it */ ring_buffer_expanded =1 ;
Signature · 1 line
1.7.6.4