public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Tommi Rantala <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, acme@redhat.com,
	alexander.shishkin@linux.intel.com, tommi.t.rantala@nokia.com,
	peterz@infradead.org, linux-kernel@vger.kernel.org,
	tglx@linutronix.de, hpa@zytor.com
Subject: [tip:perf/core] perf tests: Do not assume that readlink() returns a null terminated string
Date: Mon, 27 Mar 2017 22:57:29 -0700	[thread overview]
Message-ID: <tip-0e6ba11511aef91ba8e2528ddc681d88922d7b0b@git.kernel.org> (raw)
In-Reply-To: <20170322130624.21881-4-tommi.t.rantala@nokia.com>

Commit-ID:  0e6ba11511aef91ba8e2528ddc681d88922d7b0b
Gitweb:     http://git.kernel.org/tip/0e6ba11511aef91ba8e2528ddc681d88922d7b0b
Author:     Tommi Rantala <tommi.t.rantala@nokia.com>
AuthorDate: Wed, 22 Mar 2017 15:06:21 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 27 Mar 2017 15:35:56 -0300

perf tests: Do not assume that readlink() returns a null terminated string

Ensure that the string in buf is null terminated.

Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170322130624.21881-4-tommi.t.rantala@nokia.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/sdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index f59d210..26e5b7a 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -43,7 +43,7 @@ static char *get_self_path(void)
 {
 	char *buf = calloc(PATH_MAX, sizeof(char));
 
-	if (buf && readlink("/proc/self/exe", buf, PATH_MAX) < 0) {
+	if (buf && readlink("/proc/self/exe", buf, PATH_MAX - 1) < 0) {
 		pr_debug("Failed to get correct path of perf\n");
 		free(buf);
 		return NULL;

  reply	other threads:[~2017-03-28  6:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 13:06 [PATCH 0/6] perf string handling fixes Tommi Rantala
2017-03-22 13:06 ` [PATCH 1/6] perf buildid: do not update SDT cache with null filename Tommi Rantala
2017-03-28  5:56   ` [tip:perf/core] perf buildid: Do " tip-bot for Tommi Rantala
2017-03-22 13:06 ` [PATCH 2/6] perf buildid: do not assume that readlink() returns a null terminated string Tommi Rantala
2017-03-28  5:56   ` [tip:perf/core] perf buildid: Do " tip-bot for Tommi Rantala
2017-03-22 13:06 ` [PATCH 3/6] perf tests: do " Tommi Rantala
2017-03-28  5:57   ` tip-bot for Tommi Rantala [this message]
2017-03-22 13:06 ` [PATCH 4/6] perf utils: use sizeof(buf)-1 in readlink() call Tommi Rantala
2017-03-28  5:58   ` [tip:perf/core] perf utils: use sizeof(buf) - 1 " tip-bot for Tommi Rantala
2017-03-22 13:06 ` [PATCH 5/6] perf utils: null terminate buf in read_ftrace_printk() Tommi Rantala
2017-03-27 18:28   ` Arnaldo Carvalho de Melo
2017-03-28  5:58   ` [tip:perf/core] perf utils: Null " tip-bot for Tommi Rantala
2017-03-22 13:06 ` [PATCH 6/6] perf utils: readlink /proc/self/exe to find the perf binary Tommi Rantala
2017-03-28  5:59   ` [tip:perf/core] perf utils: Readlink " tip-bot for Tommi Rantala
2017-03-27 18:38 ` [PATCH 0/6] perf string handling fixes Arnaldo Carvalho de Melo

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=tip-0e6ba11511aef91ba8e2528ddc681d88922d7b0b@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tommi.t.rantala@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox