mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
Fix a memory exhaustion bug when attempting to allocate room for an impossible number of program headers.
* elfcode.h (elf_object_p): Check for corrupt input files with more program headers than can actually fit in the file.
This commit is contained in:
parent
beab453223
commit
5f60af5d24
@ -1,3 +1,8 @@
|
||||
2018-11-30 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* elfcode.h (elf_object_p): Check for corrupt input files with
|
||||
more program headers than can actually fit in the file.
|
||||
|
||||
2018-11-30 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 23932
|
||||
|
@ -784,6 +784,11 @@ elf_object_p (bfd *abfd)
|
||||
if (i_ehdrp->e_phnum > ((bfd_size_type) -1) / sizeof (*i_phdr))
|
||||
goto got_wrong_format_error;
|
||||
#endif
|
||||
/* Check for a corrupt input file with an impossibly large number
|
||||
of program headers. */
|
||||
if (bfd_get_file_size (abfd) > 0
|
||||
&& i_ehdrp->e_phnum > bfd_get_file_size (abfd))
|
||||
goto got_no_match;
|
||||
amt = (bfd_size_type) i_ehdrp->e_phnum * sizeof (*i_phdr);
|
||||
elf_tdata (abfd)->phdr = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt);
|
||||
if (elf_tdata (abfd)->phdr == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user