diff options
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r-- | bfd/coffgen.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 4725406..05f2640 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1551,6 +1551,7 @@ _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; @@ -1565,6 +1566,15 @@ _bfd_coff_get_external_symbols (bfd *abfd) if (size == 0) return true; + filesize = bfd_get_file_size (abfd); + if (filesize != 0 + && ((ufile_ptr) obj_sym_filepos (abfd) > filesize + || size > filesize - obj_sym_filepos (abfd))) + { + bfd_set_error (bfd_error_file_truncated); + return false; + } + if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) return false; syms = _bfd_malloc_and_read (abfd, size, size); |