diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2010-06-15 12:29:15 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-28 21:11:39 -0400 |
commit | d62f85d1e22e537192ce494c89540e1ac0d8bfc7 (patch) | |
tree | 6ea77c37dbdc9d0b82ca93ace71ffe5f44f234d3 /kernel/trace/trace_functions_graph.c | |
parent | 67ead0a6ceb001b4cb891d782e440f0e79493ba2 (diff) |
tracing/function-graph: Use correct string size for snprintf
The nsecs_str string is a local variable defined as:
char nsecs_str[5];
It is possible for the snprintf call to use a size value larger than the
size of the string. This should not cause a buffer overrun as it is
written now due to the value for the string format "%03lu" can not be
larger than 1000. However, this change makes it correct. By making the
size correct we guard against potential future changes that could actually
cause a buffer overrun.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
LKML-Reference: <1276619355-18116-1-git-send-email-chase.douglas@canonical.com>
[ added 'UL' to number 8 to fix gcc warning comparing it to sizeof() ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_functions_graph.c')
-rw-r--r-- | kernel/trace/trace_functions_graph.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 79f4bac99a94..6bff23625781 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c | |||
@@ -641,7 +641,8 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s) | |||
641 | 641 | ||
642 | /* Print nsecs (we don't want to exceed 7 numbers) */ | 642 | /* Print nsecs (we don't want to exceed 7 numbers) */ |
643 | if (len < 7) { | 643 | if (len < 7) { |
644 | snprintf(nsecs_str, 8 - len, "%03lu", nsecs_rem); | 644 | snprintf(nsecs_str, min(sizeof(nsecs_str), 8UL - len), "%03lu", |
645 | nsecs_rem); | ||
645 | ret = trace_seq_printf(s, ".%s", nsecs_str); | 646 | ret = trace_seq_printf(s, ".%s", nsecs_str); |
646 | if (!ret) | 647 | if (!ret) |
647 | return TRACE_TYPE_PARTIAL_LINE; | 648 | return TRACE_TYPE_PARTIAL_LINE; |