archive mirror
 help / color / mirror / Atom feed
From: Stephane Eranian <>
Subject: [PATCH] perf: fix strlen() bug in perf_event__synthesize_event_type() (repost)
Date: Fri, 20 Jan 2012 10:49:12 +0100	[thread overview]
Message-ID: <20120120094912.GA4882@quad> (raw)

[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 <>

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(, name, MAX_EVENT_NAME - 1);
 	ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE;
-	size = strlen(name);
+	size = strlen(;
 	size = ALIGN(size, sizeof(u64));
 	ev.event_type.header.size = sizeof(ev.event_type) -
 		(sizeof( - size);

             reply	other threads:[~2012-01-20  9:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20  9:49 Stephane Eranian [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120120094912.GA4882@quad \ \ \ \ \ \ \
    --subject='Re: [PATCH] perf: fix strlen() bug in perf_event__synthesize_event_type() (repost)' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox