LKML Archive on
 help / color / 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
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 index

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

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

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git
	git clone --mirror lkml/git/9.git
	git clone --mirror lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone