lkml.org 
[lkml]   [2017]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/6] perf tests: do not assume that readlink() returns a null terminated string
    Date
    Ensure that the string in buf is null terminated.

    Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
    ---
    tools/perf/tests/sdt.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
    index f59d210..121949a 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;
    --
    2.9.3
    \
     
     \ /
      Last update: 2017-03-22 14:09    [W:2.623 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site