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.
This commit is contained in:
Nick Clifton 2016-08-22 14:16:26 +01:00
parent 888a7fc366
commit 4ca0333f07
2 changed files with 13 additions and 0 deletions

View File

@ -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.

View File

@ -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) );