[tip:perfcounters/core] perf_counter tools: fix buffer overwrite problem for perf top command

From: tip-bot for Erdem Aktas
Date: Sun May 10 2009 - 02:25:41 EST


Commit-ID: 82afae6016b672acb90ceb8e773bba0bd977d2a3
Gitweb: http://git.kernel.org/tip/82afae6016b672acb90ceb8e773bba0bd977d2a3
Author: Erdem Aktas <eaktas1@xxxxxxxxx>
AuthorDate: Sun, 10 May 2009 02:13:19 -0400
Committer: Ingo Molnar <mingo@xxxxxxx>
CommitDate: Sun, 10 May 2009 08:21:18 +0200

perf_counter tools: fix buffer overwrite problem for perf top command

There is a buffer overwrite problem in builtin-top.c line 526, When I
tried to use ./perf top command, it was giving memory corruption
problem.

[ Impact: fix 'perf top' crash ]

LKML-Reference: <3fee128b0905092313x608e65e0l7b1116d86914114f@xxxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>


---
Documentation/perf_counter/builtin-top.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c
index cd6f61d..b1549dd 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -523,7 +523,7 @@ static int read_symbol(FILE *in, struct sym_entry *s)
if (strstr(sym, "_text_start") || strstr(sym, "_text_end"))
return 1;

- s->sym = malloc(strlen(str));
+ s->sym = malloc(strlen(str)+1);
assert(s->sym);

strcpy((char *)s->sym, str);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/