mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-14 12:37:32 +00:00
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>
This commit is contained in:
parent
5a2342111c
commit
0e6ba11511
1 changed files with 1 additions and 1 deletions
|
@ -43,7 +43,7 @@ static char *get_self_path(void)
|
||||||
{
|
{
|
||||||
char *buf = calloc(PATH_MAX, sizeof(char));
|
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");
|
pr_debug("Failed to get correct path of perf\n");
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue