Prevent endless loop by detecting broken MIPS.options

This commit is contained in:
Oleksandr Tymoshenko 2010-11-07 20:44:46 +00:00
parent db09d96dcb
commit da6dbae49c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214950

View File

@ -4330,6 +4330,15 @@ _bfd_mips_elf_section_processing (bfd *abfd, Elf_Internal_Shdr *hdr)
bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
&intopt);
if (intopt.size < sizeof (Elf_External_Options))
{
(*_bfd_error_handler)
(_("Warning: bad `%s' option size %u smaller than its header"),
MIPS_ELF_OPTIONS_SECTION_NAME (abfd), intopt.size);
break;
}
if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
{
bfd_byte buf[8];
@ -4542,6 +4551,14 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr,
bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
&intopt);
if (intopt.size < sizeof (Elf_External_Options))
{
(*_bfd_error_handler)
(_("Warning: bad `%s' option size %u smaller than its header"),
MIPS_ELF_OPTIONS_SECTION_NAME (abfd), intopt.size);
break;
}
if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
{
Elf64_Internal_RegInfo intreg;