[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111206132032.GD7059@infradead.org>
Date: Tue, 6 Dec 2011 11:20:32 -0200
From: Arnaldo Carvalho de Melo <acme@...hat.com>
To: Robert Richter <robert.richter@....com>
Cc: Ingo Molnar <mingo@...e.hu>, Peter Zijlstra <peterz@...radead.org>,
Stephane Eranian <eranian@...gle.com>,
Frederic Weisbecker <fweisbec@...il.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 04/10] perf tools: Fix out-of-bound access to struct
perf_session
Em Tue, Dec 06, 2011 at 11:32:34AM +0100, Robert Richter escreveu:
> 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.
Interesting, defensive programing, ok.
> Signed-off-by: Robert Richter <robert.richter@....com>
> ---
> tools/perf/util/session.c | 2 +-
> tools/perf/util/session.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 85c1e6b7..2ad9c10 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -132,7 +132,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
> bool force, bool repipe,
> struct perf_event_ops *ops)
> {
> - size_t len = filename ? strlen(filename) + 1 : 0;
> + size_t len = filename ? strlen(filename) : 0;
> struct perf_session *self = zalloc(sizeof(*self) + len);
>
> if (self == NULL)
> diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
> index 6e393c9..f320cd5 100644
> --- a/tools/perf/util/session.h
> +++ b/tools/perf/util/session.h
> @@ -54,7 +54,7 @@ struct perf_session {
> char *cwd;
> struct ordered_samples ordered_samples;
> struct callchain_cursor callchain_cursor;
> - char filename[0];
> + char filename[1];
> };
>
> struct perf_evsel;
> --
> 1.7.7
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists