offset = i_shdrp[shindex]->sh_offset;
shstrtabsize = i_shdrp[shindex]->sh_size;
- /* Allocate and clear an extra byte at the end, to prevent crashes
- in case the string table is not terminated. */
- if (shstrtabsize + 1 <= 1
+ if (shstrtabsize == 0
|| bfd_seek (abfd, offset, SEEK_SET) != 0
|| (shstrtab
= _bfd_mmap_readonly_persistent (abfd, shstrtabsize)) == NULL)
the string table over and over. */
i_shdrp[shindex]->sh_size = 0;
}
- else if (shstrtab[shstrtabsize - 1] != '\0')
+ else if (shstrtab[shstrtabsize - 1] != 0)
{
/* It is an error if a string table isn't terminated. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%pB(%pA): string table is corrupt"),
- abfd, i_shdrp[shindex]->bfd_section);
- return NULL;
+ (_("%pB: string table [%u] is corrupt"), abfd, shindex);
+ shstrtab[shstrtabsize - 1] = 0;
}
i_shdrp[shindex]->contents = shstrtab;
}
_bfd_error_handler
/* xgettext:c-format */
(_("%pB: DT_STRTAB table is corrupt"), abfd);
- goto error_return;
+ strbuf[dt_strsz - 1] = 0;
}
/* Get the real symbol count from DT_HASH or DT_GNU_HASH. Prefer