perf tools: Pre-check sample size before parsing

Check that the total size of the sample fields having a fixed
size do not exceed the one of the whole event. This robustifies
the sample parsing.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
This commit is contained in:
Frederic Weisbecker
2011-05-21 19:33:04 +02:00
parent 74429964d8
commit a285412479
7 changed files with 41 additions and 5 deletions

View File

@ -43,6 +43,7 @@ struct perf_session {
*/
struct hists hists;
u64 sample_type;
int sample_size;
int fd;
bool fd_pipe;
bool repipe;
@ -159,6 +160,7 @@ static inline int perf_session__parse_sample(struct perf_session *session,
struct perf_sample *sample)
{
return perf_event__parse_sample(event, session->sample_type,
session->sample_size,
session->sample_id_all, sample);
}