- 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
+ /* xgettext:c-format */
+ (_("%pB(%pA+%#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);