- string = ((char *) stabstrbuf
- + stroff
- + bfd_get_32 (abfd, sym + STRDXOFF));
- *pstridx = _bfd_stringtab_add (sinfo->strings, string, true, true);
+ symstroff = stroff + bfd_get_32 (abfd, sym + STRDXOFF);
+ if (symstroff >= stabstrsec->size)
+ {
+ (*_bfd_error_handler)
+ (_("%B(%A+0x%lx): Stabs entry has invalid string index."),
+ 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);