[binutils-gdb] Prevent a seg-fault in gprof when parsing a corrupt core file.

Nick Clifton nickc@sourceware.org
Mon Aug 22 13:17:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4ca0333f073cb4d86fe9d4e64c9dfdca5deba1e0

commit 4ca0333f073cb4d86fe9d4e64c9dfdca5deba1e0
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Aug 22 14:16:26 2016 +0100

    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.

Diff:
---
 gprof/ChangeLog  | 6 ++++++
 gprof/corefile.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/gprof/ChangeLog b/gprof/ChangeLog
index 83e8d17..eabc188 100644
--- a/gprof/ChangeLog
+++ b/gprof/ChangeLog
@@ -1,3 +1,9 @@
+2016-08-22  Nick Clifton  <nickc@redhat.com>
+
+	PR gprof/20499
+	* corefile.c (core_create_syms_from): Avoid walking off the end of
+	the symbol table.
+
 2016-07-21  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* configure: Regenerated.
diff --git a/gprof/corefile.c b/gprof/corefile.c
index 37942b5..93a0e94 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) );



More information about the Binutils-cvs mailing list