* [trace PATCH] Fix unterminated buffer if the length of str exceeds MAX_TRACER_SIZE
@ 2011-10-16 9:37 Thomas Jarosch
0 siblings, 0 replies; only message in thread
From: Thomas Jarosch @ 2011-10-16 9:37 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel
strncpy() doesn't always zero terminate the string.
Detected by "cppcheck"
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
kernel/trace/trace.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index e5df02c..9637b1e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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;
--
1.7.6.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-16 9:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-16 9:37 [trace PATCH] Fix unterminated buffer if the length of str exceeds MAX_TRACER_SIZE Thomas Jarosch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox