summaryrefslogtreecommitdiff
path: root/gprof/corefile.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-08-22 14:16:26 +0100
committerNick Clifton <nickc@redhat.com>2016-08-22 14:16:26 +0100
commit4ca0333f073cb4d86fe9d4e64c9dfdca5deba1e0 (patch)
tree2ac9a4bace8b9f16422ab3b459ab40135e364e32 /gprof/corefile.c
parent888a7fc3665a67e20da1bce2f865b0ff9ef15842 (diff)
downloadbinutils-gdb-4ca0333f073cb4d86fe9d4e64c9dfdca5deba1e0.tar.gz
Prevent a seg-fault in gprof when parsing a corrupt core file.
PR gprof/20499 * corefile.c (core_create_syms_from): Avoid walking off the end of the symbol table.
Diffstat (limited to 'gprof/corefile.c')
-rw-r--r--gprof/corefile.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gprof/corefile.c b/gprof/corefile.c
index 37942b564ad..93a0e94e554 100644
--- a/gprof/corefile.c
+++ b/gprof/corefile.c
@@ -553,6 +553,13 @@ core_create_syms_from (const char * sym_table_file)
if (type != 't' && type != 'T')
continue;
+ /* PR 20499 */
+ if ((symtab.limit - symtab.base) >= symtab.len)
+ {
+ fprintf (stderr, _("%s: too many symbols in file '%s'\n"), whoami, sym_table_file);
+ done (1);
+ }
+
sym_init (symtab.limit);
sscanf (address, "%" BFD_VMA_FMT "x", &(symtab.limit->addr) );