From: Ian Rogers Date: Sat, 26 Oct 2019 03:56:44 +0000 (-0700) Subject: perf annotate: Fix heap overflow X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5c65b1c0842f9daddc6aec4bdb4b5d898006be19;p=linux.git perf annotate: Fix heap overflow Fix expand_tabs that copies the source lines '\0' and then appends another '\0' at a potentially out of bounds address. Signed-off-by: Ian Rogers Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Jin Yao Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20191026035644.217548-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index ef1866a902c44..bee0fee122f85 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1892,7 +1892,7 @@ static char *expand_tabs(char *line, char **storage, size_t *storage_len) } /* Expand the last region. */ - len = line_len + 1 - src; + len = line_len - src; memcpy(&new_line[dst], &line[src], len); dst += len; new_line[dst] = '\0';