perf ui browser: Fix segfault caused by off by one handling END key
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 48d038fcd09fa231e254965c3b69f8f640c9e62d Gitweb: http://git.kernel.org/tip/48d038fcd09fa231e254965c3b69f8f640c9e62d Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 14 Nov 2013 15:30:41 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 14 Nov 2013 16:00:31 -0300
perf ui browser: Fix segfault caused by off by one handling END key
$ perf record ls $ perf report
Press 'down enter end'
Result:
Program received signal SIGSEGV, Segmentation fault.
The UI browser, used on a argv array would access past the end of the array on SEEK_END because it wasn't using 'nr_entries - 1', fix it.
Reported-by [email protected]
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/ui/browser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/ui/browser.c +1 -1
@@ -569,7 +569,7 @@ void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence) browser->top = browser->top + browser->top_idx + offset;break ;case SEEK_END : - browser->top = browser->top + browser->nr_entries + offset; + browser->top = browser->top + browser->nr_entries -1 + offset;break ;default :return ;