mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-14 04:26:45 +00:00
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>
This commit is contained in:
parent
0e6ba11511
commit
b7126ef786
1 changed files with 1 additions and 1 deletions
|
@ -378,7 +378,7 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused,
|
||||||
* actual atual path to perf binary
|
* actual atual path to perf binary
|
||||||
*/
|
*/
|
||||||
sprintf(proc, "/proc/%d/exe", getpid());
|
sprintf(proc, "/proc/%d/exe", getpid());
|
||||||
ret = readlink(proc, buf, sizeof(buf));
|
ret = readlink(proc, buf, sizeof(buf) - 1);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue