This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Patch: check for invalid string offsets when linking stabs
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 05 Jun 2002 15:41:47 +0100
- Subject: Patch: check for invalid string offsets when linking stabs
ld can segfault if a stabs entry contains an invalid string offset.
Is it OK to add a bounds check? Patch checked for basic sanity 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 -d -p -r1.9 stabs.c
*** stabs.c 26 Nov 2001 19:31:27 -0000 1.9
--- stabs.c 5 Jun 2002 14:13:59 -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,321 ----
}
/* 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;
! string = (char *) stabstrbuf + symstroff;
*pstridx = _bfd_stringtab_add (sinfo->strings, string, true, true);
/* An N_BINCL symbol indicates the start of the stabs entries