diff options
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r-- | bfd/coffgen.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 5287130..20cee0a 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1639,30 +1639,29 @@ copy_name (bfd *abfd, char *name, size_t maxlen) bfd_boolean _bfd_coff_get_external_symbols (bfd *abfd) { - bfd_size_type symesz; - bfd_size_type size; + size_t symesz; + size_t size; void * syms; ufile_ptr filesize; if (obj_coff_external_syms (abfd) != NULL) return TRUE; - symesz = bfd_coff_symesz (abfd); - size = obj_raw_syment_count (abfd) * symesz; - if (size == 0) - return TRUE; - /* Check for integer overflow and for unreasonable symbol counts. */ filesize = bfd_get_file_size (abfd); - if (size < obj_raw_syment_count (abfd) + symesz = bfd_coff_symesz (abfd); + if (_bfd_mul_overflow (obj_raw_syment_count (abfd), symesz, &size) || (filesize != 0 && size > filesize)) - { + 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; } + if (size == 0) + return TRUE; + syms = bfd_malloc (size); if (syms == NULL) { |