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

@ -690,8 +690,9 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
return PyErr_NoMemory();
first = list_entry(evlist->entries.next, struct perf_evsel, node);
perf_event__parse_sample(event, first->attr.sample_type, sample_id_all,
&pevent->sample);
perf_event__parse_sample(event, first->attr.sample_type,
perf_sample_size(first->attr.sample_type),
sample_id_all, &pevent->sample);
return pyevent;
}