Skip to content

Commit

Permalink
perf trace: Fix read_string()
Browse files Browse the repository at this point in the history
We did not account for the enclosing \0. Depending on what malloc()
gave us this resulted in corrupted version string printouts.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed Sep 3, 2009
1 parent 00fc978 commit 6f4596d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/perf/util/trace-event-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 6f4596d

Please sign in to comment.