Commit d8d9c282a1abbe2baf6d22f959e6adf4c90629bf
Committed by
Arnaldo Carvalho de Melo
1 parent
0a84f007f9
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
perf tools: Fix strlen() bug in perf_event__synthesize_event_type()
The event_type record has a max length for the event name. It's called MAX_EVENT_NAME. The name may be truncated to fit the max length. But the header.size still reflects the original name length. If that length is > MAX_EVENT_NAME, then the header.size field is bogus. Fix this by using the length of the name after the potential truncation. Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20120120094912.GA4882@quad Signed-off-by: Stephane Eranian <eranian@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
tools/perf/util/header.c
... | ... | @@ -2105,7 +2105,7 @@ |
2105 | 2105 | strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1); |
2106 | 2106 | |
2107 | 2107 | ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE; |
2108 | - size = strlen(name); | |
2108 | + size = strlen(ev.event_type.event_type.name); | |
2109 | 2109 | size = ALIGN(size, sizeof(u64)); |
2110 | 2110 | ev.event_type.header.size = sizeof(ev.event_type) - |
2111 | 2111 | (sizeof(ev.event_type.event_type.name) - size); |