• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision5dcae8f603b9379ef1c5f59331987322fd4d2126 (tree)
Zeit2022-10-26 15:57:45
AutorAlan Modra <amodra@gmai...>
CommiterAlan Modra

Log Message

Correct ELF reloc size sanity check

The external reloc size check was wrong. Here asect is the code/data
section, not the reloc section. So using this_hdr gave the size of
the code/data section.

* elf.c (_bfd_elf_get_reloc_upper_bound): Properly get
external size from reloc headers.

Ändern Zusammenfassung

Diff

--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8708,15 +8708,20 @@ _bfd_elf_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
87088708 if (asect->reloc_count != 0 && !bfd_write_p (abfd))
87098709 {
87108710 /* Sanity check reloc section size. */
8711- struct bfd_elf_section_data *d = elf_section_data (asect);
8712- Elf_Internal_Shdr *rel_hdr = &d->this_hdr;
8713- bfd_size_type ext_rel_size = rel_hdr->sh_size;
87148711 ufile_ptr filesize = bfd_get_file_size (abfd);
87158712
8716- if (filesize != 0 && ext_rel_size > filesize)
8713+ if (filesize != 0)
87178714 {
8718- bfd_set_error (bfd_error_file_truncated);
8719- return -1;
8715+ struct bfd_elf_section_data *d = elf_section_data (asect);
8716+ bfd_size_type rel_size = d->rel.hdr ? d->rel.hdr->sh_size : 0;
8717+ bfd_size_type rela_size = d->rela.hdr ? d->rela.hdr->sh_size : 0;
8718+
8719+ if (rel_size + rela_size > filesize
8720+ || rel_size + rela_size < rel_size)
8721+ {
8722+ bfd_set_error (bfd_error_file_truncated);
8723+ return -1;
8724+ }
87208725 }
87218726 }
87228727