diff options
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r-- | bfd/libbfd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c index be090e9b069..d76a12e0317 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -692,10 +692,12 @@ _bfd_generic_get_section_contents (bfd *abfd, file_ptr offset, bfd_size_type count) { + bfd_size_type sz; if (count == 0) return TRUE; - if (offset + count > section->_raw_size) + sz = section->rawsize ? section->rawsize : section->size; + if (offset + count > sz) { bfd_set_error (bfd_error_invalid_operation); return FALSE; @@ -717,6 +719,8 @@ _bfd_generic_get_section_contents_in_window bfd_size_type count ATTRIBUTE_UNUSED) { #ifdef USE_MMAP + bfd_size_type sz; + if (count == 0) return TRUE; if (abfd->xvec->_bfd_get_section_contents @@ -744,7 +748,8 @@ _bfd_generic_get_section_contents_in_window w->data = w->i->data; return bfd_get_section_contents (abfd, section, w->data, offset, count); } - if (offset + count > section->_raw_size + sz = section->rawsize ? section->rawsize : section->size; + if (offset + count > sz || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, TRUE)) return FALSE; |