perf tools: Fix crash in elf_section_by_name
PATCH 1/1 perf tools: Fix crash in elf_section_by_name
Fixing crash in elf_section_by_name function caused by missing section name in elf binary.
Reported-by Albert Strasheim <[email protected]>
Signed-off-by Jiri Olsa <[email protected]>
Cc Corey Ashford <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Albert Strasheim <[email protected]>
--- tools/perf/util/symbol-elf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/symbol-elf.c +3 -3
@@ -151,15 +151,15 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,gelf_getshdr (sec, shp); str =elf_strptr (elf, ep->e_shstrndx, shp->sh_name); -if (!strcmp (name, str)) { +if (str && !strcmp (name, str)) {if (idx) *idx = cnt; -break ; +return sec; } ++cnt; } -return sec; +return NULL ; }#define elf_section__for_each_rel (reldata, pos, pos_mem, idx, nr_entries) \
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf symbols: Fix crash in elf_section_by_name
perf symbols: Fix crash in elf_section_by_name
Commit-ID: 155b3a13a65d4217316dbe094843f2a7df0711fa Gitweb: http://git.kernel.org/tip/155b3a13a65d4217316dbe094843f2a7df0711fa Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 2 Mar 2014 14:32:07 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 10 Mar 2014 11:17:14 -0300
perf symbols: Fix crash in elf_section_by_name
Fixing crash in elf_section_by_name function caused by missing section name in elf binary.
Reported-by Albert Strasheim <[email protected]>
Signed-off-by Jiri Olsa <[email protected]>
Cc Albert Strasheim <[email protected]>
Cc Corey Ashford <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/symbol-elf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/symbol-elf.c +3 -3
@@ -151,15 +151,15 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,gelf_getshdr (sec, shp); str =elf_strptr (elf, ep->e_shstrndx, shp->sh_name); -if (!strcmp (name, str)) { +if (str && !strcmp (name, str)) {if (idx) *idx = cnt; -break ; +return sec; } ++cnt; } -return sec; +return NULL ; }#define elf_section__for_each_rel (reldata, pos, pos_mem, idx, nr_entries) \