This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Patch: check for invalid string offsets when linking stabs
Alan Modra <amodra@bigpond.net.au> writes:
> > /* Store the string in the hash table, and record the index. */
> > ! symstroff = stroff + bfd_get_32 (abfd, sym + STRDXOFF);
> > ! if (symstroff >= stabstrsec->_raw_size)
> > ! goto error_return;
>
> bfd_set_error, and print a warning via _bfd_error_handler.
Argh, sorry. How's this? Tested on mips64-elf.
Richard
* stabs.c (_bfd_link_section_stabs): Check that the symbol offset
is within the .stabstr section.
Index: stabs.c
===================================================================
RCS file: /cvs/src/src/bfd/stabs.c,v
retrieving revision 1.9
diff -c -p -d -r1.9 stabs.c
*** stabs.c 26 Nov 2001 19:31:27 -0000 1.9
--- stabs.c 6 Jun 2002 08:32:02 -0000
*************** _bfd_link_section_stabs (abfd, psinfo, s
*** 284,289 ****
--- 284,290 ----
sym < symend;
sym += STABSIZE, ++pstridx)
{
+ bfd_size_type symstroff;
int type;
const char *string;
*************** _bfd_link_section_stabs (abfd, psinfo, s
*** 311,319 ****
}
/* Store the string in the hash table, and record the index. */
! string = ((char *) stabstrbuf
! + stroff
! + bfd_get_32 (abfd, sym + STRDXOFF));
*pstridx = _bfd_stringtab_add (sinfo->strings, string, true, true);
/* An N_BINCL symbol indicates the start of the stabs entries
--- 312,329 ----
}
/* Store the string in the hash table, and record the index. */
! 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