All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: fix strlen() bug in perf_event__synthesize_event_type() (repost)
@ 2012-01-20  9:49 Stephane Eranian
  2012-01-26 13:36 ` [tip:perf/core] perf tools: Fix strlen() bug in perf_event__synthesize_event_type() tip-bot for Stephane Eranian
  2012-01-31 13:24 ` tip-bot for Stephane Eranian
  0 siblings, 2 replies; 3+ messages in thread
From: Stephane Eranian @ 2012-01-20  9:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: acme, peterz, mingo, dsahern

[repost because of typo in Ingo's email address]

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.
    
Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 3e7e0b0..ecd7f4d 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2105,7 +2105,7 @@ int perf_event__synthesize_event_type(struct perf_tool *tool,
 	strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1);
 
 	ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE;
-	size = strlen(name);
+	size = strlen(ev.event_type.event_type.name);
 	size = ALIGN(size, sizeof(u64));
 	ev.event_type.header.size = sizeof(ev.event_type) -
 		(sizeof(ev.event_type.event_type.name) - size);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-31 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20  9:49 [PATCH] perf: fix strlen() bug in perf_event__synthesize_event_type() (repost) Stephane Eranian
2012-01-26 13:36 ` [tip:perf/core] perf tools: Fix strlen() bug in perf_event__synthesize_event_type() tip-bot for Stephane Eranian
2012-01-31 13:24 ` tip-bot for Stephane Eranian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.