aboutsummaryrefslogtreecommitdiff
path: root/binutils/stabs.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2018-03-13 17:03:04 +0000
committerNick Clifton <nickc@redhat.com>2018-03-13 17:03:04 +0000
commite45ad1239d7d8591d5e80d8cbba7d404c6c3640f (patch)
tree90569ed241dc0202892a8eefdb677d61057978db /binutils/stabs.c
parentb4a3689a68d88291d5aa73b9179322f58b562db7 (diff)
downloadgdb-e45ad1239d7d8591d5e80d8cbba7d404c6c3640f.zip
gdb-e45ad1239d7d8591d5e80d8cbba7d404c6c3640f.tar.gz
gdb-e45ad1239d7d8591d5e80d8cbba7d404c6c3640f.tar.bz2
Prevent a buffer overrun when parsing corrupt STABS debug information.
PR 22957 * stabs.c (pop_binincl): Fail if the file index is off the end of the stack.
Diffstat (limited to 'binutils/stabs.c')
-rw-r--r--binutils/stabs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/binutils/stabs.c b/binutils/stabs.c
index 807ca1e..bf53607 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -449,7 +449,6 @@ parse_stab (void *dhandle, void *handle, int type, int desc, bfd_vma value,
info->file_types = ((struct stab_types **)
xmalloc (sizeof *info->file_types));
info->file_types[0] = NULL;
-
info->so_string = NULL;
/* Now process whatever type we just got. */
@@ -3326,6 +3325,9 @@ pop_bincl (struct stab_handle *info)
return info->main_filename;
info->bincl_stack = o->next_stack;
+ if (o->file >= info->files)
+ return info->main_filename;
+
o->file_types = info->file_types[o->file];
if (info->bincl_stack == NULL)