aboutsummaryrefslogtreecommitdiff
path: root/bfd/stabs.c
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2002-06-06 09:24:56 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2002-06-06 09:24:56 +0000
commit644c4c80f9dd4e06eb9cae2ae391e2b4f2b36fff (patch)
treef74f1884005aad66472bf9fe9a4cbe9ef14a814d /bfd/stabs.c
parentec8b3afdf273b2d682ce02a5d4f594d3fa5cf268 (diff)
downloadgdb-644c4c80f9dd4e06eb9cae2ae391e2b4f2b36fff.zip
gdb-644c4c80f9dd4e06eb9cae2ae391e2b4f2b36fff.tar.gz
gdb-644c4c80f9dd4e06eb9cae2ae391e2b4f2b36fff.tar.bz2
* stabs.c (_bfd_link_section_stabs): Check that the symbol offset
is within the .stabstr section.
Diffstat (limited to 'bfd/stabs.c')
-rw-r--r--bfd/stabs.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/bfd/stabs.c b/bfd/stabs.c
index bba4a6d..e225d9c 100644
--- a/bfd/stabs.c
+++ b/bfd/stabs.c
@@ -284,6 +284,7 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo)
sym < symend;
sym += STABSIZE, ++pstridx)
{
+ bfd_size_type symstroff;
int type;
const char *string;
@@ -311,9 +312,18 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo)
}
/* Store the string in the hash table, and record the index. */
- string = ((char *) stabstrbuf
- + stroff
- + bfd_get_32 (abfd, sym + STRDXOFF));
+ symstroff = stroff + bfd_get_32 (abfd, sym + STRDXOFF);
+ if (symstroff >= stabstrsec->_raw_size)
+ {
+ (*_bfd_error_handler)
+ (_("%s(%s+0x%lx): Stabs entry has invalid string index."),
+ bfd_archive_filename (abfd),
+ bfd_get_section_name (abfd, stabsec),
+ (long) (sym - stabbuf));
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ string = (char *) stabstrbuf + symstroff;
*pstridx = _bfd_stringtab_add (sinfo->strings, string, true, true);
/* An N_BINCL symbol indicates the start of the stabs entries