From: Ian Lance Taylor Date: Thu, 19 May 1994 21:58:45 +0000 (+0000) Subject: Make map_program_segments tend to call abort rather than trash the X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6731b89c4b4854e8e05a43a79be9e24ff38412a6;p=binutils-gdb.git Make map_program_segments tend to call abort rather than trash the stack in unhandled cases. Still covered by previous ChangeLog entry. --- diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 62114bbfa4e..bdedb487e69 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1824,7 +1824,7 @@ map_program_segments (abfd, off, first, phdr_size) Elf_Internal_Shdr *first; bfd_size_type phdr_size; { - Elf_Internal_Phdr phdrs[5]; + Elf_Internal_Phdr phdrs[10]; unsigned int phdr_count; Elf_Internal_Phdr *phdr; int phdr_size_adjust; @@ -1835,6 +1835,8 @@ map_program_segments (abfd, off, first, phdr_size) Elf_Internal_Ehdr *i_ehdrp; BFD_ASSERT ((abfd->flags & EXEC_P) != 0); + BFD_ASSERT (phdr_size / sizeof (Elf_Internal_Phdr) + <= sizeof phdrs / sizeof (phdrs[0])); phdr_count = 0; phdr = phdrs; @@ -1996,10 +1998,6 @@ map_program_segments (abfd, off, first, phdr_size) ++phdr_count; } - /* Make sure we didn't run off our array. */ - if (phdr_count > sizeof (phdrs) / sizeof (phdr[0])) - abort (); - /* Make sure the return value from get_program_header_size matches what we computed here. */ if (phdr_count != phdr_size / sizeof (Elf_Internal_Phdr))