Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754485AbdC1GAl (ORCPT ); Tue, 28 Mar 2017 02:00:41 -0400 Received: from terminus.zytor.com ([65.50.211.136]:42679 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753680AbdC1GAk (ORCPT ); Tue, 28 Mar 2017 02:00:40 -0400 Date: Mon, 27 Mar 2017 22:58:00 -0700 From: tip-bot for Tommi Rantala Message-ID: Cc: mingo@kernel.org, acme@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, alexander.shishkin@linux.intel.com, tommi.t.rantala@nokia.com, hpa@zytor.com Reply-To: peterz@infradead.org, alexander.shishkin@linux.intel.com, hpa@zytor.com, tommi.t.rantala@nokia.com, tglx@linutronix.de, mingo@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org In-Reply-To: <20170322130624.21881-5-tommi.t.rantala@nokia.com> References: <20170322130624.21881-5-tommi.t.rantala@nokia.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf utils: use sizeof(buf) - 1 in readlink() call Git-Commit-ID: b7126ef78612a3d4a37aadf39125cff048cebb9b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1272 Lines: 33 Commit-ID: b7126ef78612a3d4a37aadf39125cff048cebb9b Gitweb: http://git.kernel.org/tip/b7126ef78612a3d4a37aadf39125cff048cebb9b Author: Tommi Rantala AuthorDate: Wed, 22 Mar 2017 15:06:22 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 27 Mar 2017 15:36:27 -0300 perf utils: use sizeof(buf) - 1 in readlink() call Ensure that we have space for the null byte in buf. Signed-off-by: Tommi Rantala Cc: Alexander Shishkin Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20170322130624.21881-5-tommi.t.rantala@nokia.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 05714d5..cf22962 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -378,7 +378,7 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused, * actual atual path to perf binary */ sprintf(proc, "/proc/%d/exe", getpid()); - ret = readlink(proc, buf, sizeof(buf)); + ret = readlink(proc, buf, sizeof(buf) - 1); if (ret <= 0) return -1;