diff options
author | Alan Modra <amodra@gmail.com> | 2021-10-29 15:09:52 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-10-29 17:22:32 +1030 |
commit | c45c3dba8cc80a41c4e0839df43c435c7aa0996d (patch) | |
tree | 416b94ca907560ba4ddfebc3b6fa437cf3d44d2c /bfd/elfcode.h | |
parent | c82ebeb7e6e060dacbaef02933b5f06c10f574f6 (diff) | |
download | binutils-c45c3dba8cc80a41c4e0839df43c435c7aa0996d.zip binutils-c45c3dba8cc80a41c4e0839df43c435c7aa0996d.tar.gz binutils-c45c3dba8cc80a41c4e0839df43c435c7aa0996d.tar.bz2 |
ELF core file size checks
Catch fuzzed segments where p_offset + p_filesz wraps, and limit error
output.
* elfcore.h (elf_core_file_p): Rewrite segment checks using
bfd_get_file_size. Set read_only on file size errors.
* elfcode.h (elf_swap_shdr_in): Don't repeat error message.
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r-- | bfd/elfcode.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 7eb27c2..ee88fce 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -325,9 +325,10 @@ elf_swap_shdr_in (bfd *abfd, && ((ufile_ptr) dst->sh_offset > filesize || dst->sh_size > filesize - dst->sh_offset)) { + if (!abfd->read_only) + _bfd_error_handler (_("warning: %pB has a section " + "extending past end of file"), abfd); abfd->read_only = 1; - _bfd_error_handler (_("warning: %pB has a section " - "extending past end of file"), abfd); } } dst->sh_link = H_GET_32 (abfd, src->sh_link); |