From: Chase Douglas <chase.douglas@canonical.com>
To: Steven Rostedt <srostedt@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] trace-cmd: prevent print_graph_duration buffer overflow
Date: Sun, 13 Jun 2010 13:11:48 -0400 [thread overview]
Message-ID: <1276449108-21328-2-git-send-email-chase.douglas@canonical.com> (raw)
In-Reply-To: <1276449108-21328-1-git-send-email-chase.douglas@canonical.com>
Passing n > sizeof(string) to snprintf can cause a glibc buffer overflow
condition. We know the exact size of nsecs_str, so use it instead of
math that may overflow.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
---
trace-ftrace.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/trace-ftrace.c b/trace-ftrace.c
index af9ac8d..ee7c6dc 100644
--- a/trace-ftrace.c
+++ b/trace-ftrace.c
@@ -148,7 +148,7 @@ static void print_graph_duration(struct trace_seq *s, unsigned long long duratio
/* Print nsecs (we don't want to exceed 7 numbers) */
if ((s->len - len) < 7) {
- snprintf(nsecs_str, 8 - (s->len - len), "%03lu", nsecs_rem);
+ snprintf(nsecs_str, sizeof(nsecs_str), "%03lu", nsecs_rem);
trace_seq_printf(s, ".%s", nsecs_str);
}
--
1.7.0.4
next prev parent reply other threads:[~2010-06-13 17:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-13 17:11 [PATCH] trace-cmd: append to CFLAGS instead of being overriden Chase Douglas
2010-06-13 17:11 ` Chase Douglas [this message]
2010-06-13 20:52 ` [PATCH] trace-cmd: prevent print_graph_duration buffer overflow Valdis.Kletnieks
2010-06-13 21:01 ` Chase Douglas
2010-06-14 21:40 ` Valdis.Kletnieks
2010-06-15 0:16 ` Steven Rostedt
2010-06-15 12:49 ` Frederic Weisbecker
2010-06-15 13:04 ` Chase Douglas
2010-06-15 13:10 ` Frederic Weisbecker
2010-06-15 13:20 ` Chase Douglas
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=1276449108-21328-2-git-send-email-chase.douglas@canonical.com \
--to=chase.douglas@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=srostedt@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
all inboxes | Powered by JetHome®