aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2011-12-07 04:02:52 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-12-23 13:57:41 -0500
commit002c4fd92d772becf8745b9cbcebe5c95fe6dad0 (patch)
treec1e740bbefb3a91ee64315a419835cd28540bb35 /tools
parentf7a8a1336416883dc0ccd96c17c604e34de61c25 (diff)
perf tools: Fix out-of-bound access to struct perf_session
If filename is NULL there is an out-of-bound access to struct perf_session if it would be used with perf_session__open(). Shouldn't actually happen in current implementation as filename is always !NULL. Fixing this by always null-terminating filename. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1323248577-11268-3-git-send-email-robert.richter@amd.com Signed-off-by: Robert Richter <robert.richter@amd.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/session.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d9318d8a9ba1..ea17dfb85baa 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -107,7 +107,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
107 bool force, bool repipe, 107 bool force, bool repipe,
108 struct perf_tool *tool) 108 struct perf_tool *tool)
109{ 109{
110 size_t len = filename ? strlen(filename) + 1 : 0; 110 size_t len = filename ? strlen(filename) : 0;
111 struct perf_session *self = zalloc(sizeof(*self) + len); 111 struct perf_session *self = zalloc(sizeof(*self) + len);
112 112
113 if (self == NULL) 113 if (self == NULL)
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index fb696124ad61..37bc38381fb6 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -50,7 +50,7 @@ struct perf_session {
50 int cwdlen; 50 int cwdlen;
51 char *cwd; 51 char *cwd;
52 struct ordered_samples ordered_samples; 52 struct ordered_samples ordered_samples;
53 char filename[0]; 53 char filename[1];
54}; 54};
55 55
56struct perf_tool; 56struct perf_tool;