diff options
author | Tommi Rantala <tommi.t.rantala@nokia.com> | 2017-03-22 16:06:21 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-03-27 21:35:56 +0300 |
commit | 0e6ba11511aef91ba8e2528ddc681d88922d7b0b (patch) | |
tree | bfd066a73068f97059534cd3965a29a6041ea2ed /tools/perf/tests/sdt.c | |
parent | 5a2342111c68e623e27ee7ea3d0492d8dad6bda0 (diff) | |
download | linux-0e6ba11511aef91ba8e2528ddc681d88922d7b0b.tar.xz |
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>
Diffstat (limited to 'tools/perf/tests/sdt.c')
-rw-r--r-- | tools/perf/tests/sdt.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c index f59d210e1baf..26e5b7a0b839 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; |