diff options
author | Alan Modra <amodra@gmail.com> | 2020-02-19 13:14:05 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-02-19 13:14:05 +1030 |
commit | 7c5fa58ea907c46817b915ec8b9b35a180e0e74c (patch) | |
tree | d5c326c134a432d499251b2e71e0f42b807adc89 /bfd/elf-attrs.c | |
parent | 96d3b80f5498c0aa40099f37f6384f2041df045f (diff) | |
download | gdb-7c5fa58ea907c46817b915ec8b9b35a180e0e74c.zip gdb-7c5fa58ea907c46817b915ec8b9b35a180e0e74c.tar.gz gdb-7c5fa58ea907c46817b915ec8b9b35a180e0e74c.tar.bz2 |
bfd_get_file_size calls
bfd_get_file_size can return 0, meaning the file size is unknown.
* coffgen.c (_bfd_coff_get_external_symbols): Don't call
bfd_get_file_size twice.
(_bfd_coff_read_string_table): Allow for bfd_get_file_size
zero, ie. unknown, return.
* elf-attrs.c (_bfd_elf_parse_attributes): Likewise.
* elfcode.h (elf_swap_shdr_in): Likewise.
(elf_object_p): Don't call bfd_get_file_size twice and correct
file size check.
Diffstat (limited to 'bfd/elf-attrs.c')
-rw-r--r-- | bfd/elf-attrs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index 169b697..070104c 100644 --- a/bfd/elf-attrs.c +++ b/bfd/elf-attrs.c @@ -436,11 +436,14 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) bfd_byte *p_end; bfd_vma len; const char *std_sec; + ufile_ptr filesize; /* PR 17512: file: 2844a11d. */ if (hdr->sh_size == 0) return; - if (hdr->sh_size > bfd_get_file_size (abfd)) + + filesize = bfd_get_file_size (abfd); + if (filesize != 0 && hdr->sh_size > filesize) { /* xgettext:c-format */ _bfd_error_handler (_("%pB: error: attribute section '%pA' too big: %#llx"), |