mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 06:45:56 +08:00
More fixes for memory access errors triggered by attemps to examine corrupted binaries.
PR binutils/17512 * dwarf.c (display_block): Do nothing if the block starts after the end of the buffer. (read_and_display_attr_value): Add range checks. (struct Frame_Chunk): Make the ncols and ra fields unsigned. (frame_need_space): Test for an ncols of zero. (read_cie): Fail if the augmentation data extends off the end of the buffer. (display_debug_frames): Add checks for read_cie failing. Add range checks. * coff-h8300.c (rtype2howto): Replace abort with returning a NULL value. * coff-h8500.c (rtype2howto): Likewise. * coff-tic30.c (rtype2howto): Likewise. * coff-z80.c (rtype2howto): Likewise. * coff-z8k.c (rtype2howto): Likewise. * coff-ia64.c (RTYPE2HOWTO): Always return a valid howto. * coff-m68k.c (m68k_rtype2howto): Return a NULL howto if none could be found. * coff-mcore.c (RTYPE2HOWTO): Add range checking. * coff-w65.c (rtype2howto): Likewise. * coff-we32k.c (RTYPE2HOWTO): Likewise. * pe-mips.c (RTYPE2HOWTO): Likewise. * coff-x86_64.c (coff_amd64_reloc): Likewise. Replace abort with an error return. * coffcode.h (coff_slurp_reloc_table): Allow the rel parameter to be unused. * coffgen.c (make_a_section_from_file): Check the length of a section name before testing to see if it is a debug section name. (coff_object_p): Zero out any uninitialised bytes in the opt header. * ecoff.c (_bfd_ecoff_slurp_symbolic_info): Test for the raw source being empty when there are values to be processed. (_bfd_ecoff_slurp_symbol_table): Add range check. * mach-o.c (bfd_mach_o_canonicalize_one_reloc): Likewise. (bfd_mach_o_mangle_sections): Move test for too many sections to before the allocation of the section table. (bfd_mach_o_read_symtab_strtab): If the read fails, free the memory and nullify the symbol pointer. * reloc.c (bfd_generic_get_relocated_section_contents): Add handling of a bfd_reloc_notsupported return value. * versados.c (EDATA): Add range checking. (get_record): Likewise. (process_otr): Check for contents being available before updating them. (versados_canonicalize_reloc): Add range check.
This commit is contained in:
@ -273,16 +273,15 @@ mcore_coff_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
|
||||
}
|
||||
#undef HOW2MAP
|
||||
|
||||
#define NUM_HOWTOS NUM_ELEM (mcore_coff_howto_table)
|
||||
|
||||
static reloc_howto_type *
|
||||
mcore_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < (sizeof (mcore_coff_howto_table)
|
||||
/ sizeof (mcore_coff_howto_table[0]));
|
||||
i++)
|
||||
for (i = 0; i < NUM_HOWTOS; i++)
|
||||
if (mcore_coff_howto_table[i].name != NULL
|
||||
&& strcasecmp (mcore_coff_howto_table[i].name, r_name) == 0)
|
||||
return &mcore_coff_howto_table[i];
|
||||
@ -290,8 +289,11 @@ mcore_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = mcore_coff_howto_table + (dst)->r_type;
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
((cache_ptr)->howto = \
|
||||
((dst)->r_type < NUM_HOWTOS \
|
||||
? mcore_coff_howto_table + (dst)->r_type \
|
||||
: NULL))
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_mcore_rtype_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
|
||||
@ -303,7 +305,7 @@ coff_mcore_rtype_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
|
||||
{
|
||||
reloc_howto_type * howto;
|
||||
|
||||
if (rel->r_type >= NUM_ELEM (mcore_coff_howto_table))
|
||||
if (rel->r_type >= NUM_HOWTOS)
|
||||
return NULL;
|
||||
|
||||
howto = mcore_coff_howto_table + rel->r_type;
|
||||
|
Reference in New Issue
Block a user