aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffgen.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-02-19 13:22:39 +1030
committerAlan Modra <amodra@gmail.com>2020-02-19 14:00:55 +1030
commit2c7c5554df19e410ea3a7d78b0c1435967a4bc62 (patch)
treeef0005f480637a4a474d1b23ff632caae8bf129c /bfd/coffgen.c
parent2bb3687ba8720558082d1575823868286d7916b5 (diff)
downloadfsf-binutils-gdb-2c7c5554df19e410ea3a7d78b0c1435967a4bc62.zip
fsf-binutils-gdb-2c7c5554df19e410ea3a7d78b0c1435967a4bc62.tar.gz
fsf-binutils-gdb-2c7c5554df19e410ea3a7d78b0c1435967a4bc62.tar.bz2
file size check in _bfd_alloc_and_read
* coffgen.c (_bfd_coff_get_external_symbols): Remove file size check. * elf.c (bfd_elf_get_str_section): Likewise. (_bfd_elf_slurp_version_tables): Likewise. * libbfd-in.h (_bfd_constant_p): Define. (_bfd_alloc_and_read, _bfd_malloc_and_read): Check read size against file size before allocating memory. * libbfd.h: Regenerate.
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r--bfd/coffgen.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index dda9839..daaaba9 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1632,20 +1632,14 @@ _bfd_coff_get_external_symbols (bfd *abfd)
size_t symesz;
size_t size;
void * syms;
- ufile_ptr filesize;
if (obj_coff_external_syms (abfd) != NULL)
return TRUE;
- /* Check for integer overflow and for unreasonable symbol counts. */
- filesize = bfd_get_file_size (abfd);
symesz = bfd_coff_symesz (abfd);
- if (_bfd_mul_overflow (obj_raw_syment_count (abfd), symesz, &size)
- || (filesize != 0 && size > filesize))
+ if (_bfd_mul_overflow (obj_raw_syment_count (abfd), symesz, &size))
{
bfd_set_error (bfd_error_file_truncated);
- _bfd_error_handler (_("%pB: corrupt symbol count: %#" PRIx64 ""),
- abfd, (uint64_t) obj_raw_syment_count (abfd));
return FALSE;
}