Commit b7126ef7 authored by Tommi Rantala's avatar Tommi Rantala Committed by Arnaldo Carvalho de Melo

perf utils: use sizeof(buf) - 1 in readlink() call

Ensure that we have space for the null byte in buf.
Signed-off-by: default avatarTommi 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0e6ba115
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment