From: Ingo Molnar Date: Thu, 3 Sep 2009 14:22:45 +0000 (+0200) Subject: perf trace: Fix read_string() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6f4596d9312ba5fbf5f3231ef484823c4e684d2e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git perf trace: Fix read_string() We did not account for the enclosing \0. Depending on what malloc() gave us this resulted in corrupted version string printouts. Cc: Peter Zijlstra Cc: Mike Galbraith Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: Frederic Weisbecker LKML-Reference: Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index b12e4903739a..a1217a10632f 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -113,8 +113,11 @@ static char *read_string(void) } } + /* trailing \0: */ + i++; + /* move the file descriptor to the end of the string */ - r = lseek(input_fd, -(r - (i+1)), SEEK_CUR); + r = lseek(input_fd, -(r - i), SEEK_CUR); if (r < 0) die("lseek");