perf annotate: fix heap overflow
Ian Rogers
reviewerPATCH 1/1 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.
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -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' ;
Signature · 1 line
2.24.0.rc0.303.g954a862665-goog
Quoted 2 lines · Ian Rogers
Fix
expand_tabsthat copies the source lines '\0' and then appends another '\0' at a potentially out of bounds address.
not sure it could get out of bounds, but i think
the change is right, it matches the memcpy before
and I dont see reason to add +1
thanks,
jirka
Quoted 22 lines
Signed-off-by Ian Rogers <[email protected]>--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/annotate.c +1
-1@@ -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' ;Signature · 1 line
2.24.0.rc0.303.g954a862665-goog
Arnaldo Carvalho de Melo
AppliedEm Mon, Oct 28, 2019 at 08:29:08PM +0100, Jiri Olsa escreveu:
Quoted 9 lines · Ian Rogers
Quoted 2 lines
Fix
expand_tabsthat copies the source lines '\0' and then appends another '\0' at a potentially out of bounds address.not sure it could get out of bounds, but i think
the change is right, it matches the memcpy before
and I dont see reason to add +1Acked-by Jiri Olsa <[email protected]>
Thanks, applied,
- Arnaldo
[tip: perf/core] perf annotate: Fix heap overflow
In reply to Ian RogersThe following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 5c65b1c0842f9daddc6aec4bdb4b5d898006be19 Gitweb: https://git.kernel.org/tip/5c65b1c0842f9daddc6aec4bdb4b5d898006be19 Author: Ian Rogers <[email protected]> AuthorDate: Fri, 25 Oct 2019 20:56:44 -07:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Thu, 07 Nov 2019 08:30:18 -03:00
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.
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -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' ;