From: Thomas Jarosch <thomas.jarosch@intra2net.com>
To: Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [trace PATCH] Fix unterminated buffer if the length of str exceeds MAX_TRACER_SIZE
Date: Sun, 16 Oct 2011 11:37:37 +0200 [thread overview]
Message-ID: <4E9AA5E1.90001@intra2net.com> (raw)
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
reply other threads:[~2011-10-16 9:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E9AA5E1.90001@intra2net.com \
--to=thomas.jarosch@intra2net.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox