This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] COFF buffer overflow in mark_relocs
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 15 Jul 2016 09:37:04 -0000
- Subject: [binutils-gdb] COFF buffer overflow in mark_relocs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=06ab6faf83ce47ca64198819eee02e4e56dc5a74
commit 06ab6faf83ce47ca64198819eee02e4e56dc5a74
Author: Alan Modra <amodra@gmail.com>
Date: Fri Jul 15 17:02:00 2016 +0930
COFF buffer overflow in mark_relocs
* cofflink.c (mark_relocs): Exclude relocs with -1 r_symndx
from marking sym_indices.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/cofflink.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a889e56..0fa96f2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-15 Alan Modra <amodra@gmail.com>
+
+ * cofflink.c (mark_relocs): Exclude relocs with -1 r_symndx
+ from marking sym_indices.
+
2016-07-14 Maciej W. Rozycki <macro@imgtec.com>
* reloc.c (bfd_perform_relocation): Try the `howto' handler
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index bcdf778..0f6ef59 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -1398,7 +1398,8 @@ mark_relocs (struct coff_final_link_info *flaginfo, bfd *input_bfd)
in the relocation table. This will then be picked up in the
skip/don't-skip pass. */
for (; irel < irelend; irel++)
- flaginfo->sym_indices[ irel->r_symndx ] = -1;
+ if ((unsigned long) irel->r_symndx < obj_raw_syment_count (input_bfd))
+ flaginfo->sym_indices[irel->r_symndx] = -1;
}
}