summaryrefslogtreecommitdiff
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorTommi Rantala <tommi.t.rantala@nokia.com>2017-03-22 16:06:22 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-03-27 21:36:27 +0300
commitb7126ef78612a3d4a37aadf39125cff048cebb9b (patch)
tree27c578f26aafda5fe9d96f2770217d34712552bb /tools/perf/util/header.c
parent0e6ba11511aef91ba8e2528ddc681d88922d7b0b (diff)
downloadlinux-b7126ef78612a3d4a37aadf39125cff048cebb9b.tar.xz
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 <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-5-tommi.t.rantala@nokia.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 05714d548584..cf22962ce725 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;