2017-06-28 H.J. Lu <hongjiu.lu@intel.com>
+ * libbfd.c (_bfd_generic_get_section_contents): Don't call
+ bfd_get_file_size. Check archive element size.
+ (_bfd_generic_get_section_contents_in_window): Likewise.
+
+2017-06-28 H.J. Lu <hongjiu.lu@intel.com>
+
* bfd-in2.h: Regenerated.
* bfdio.c (bfd_get_size): Change return type to ufile_ptr.
(bfd_get_file_size): Likewise.
bfd_size_type count)
{
bfd_size_type sz;
- ufile_ptr filesz;
if (count == 0)
return TRUE;
sz = section->rawsize;
else
sz = section->size;
- filesz = bfd_get_file_size (abfd);
if (offset + count < count
|| offset + count > sz
- || (ufile_ptr) section->filepos + offset + count > filesz)
+ || (abfd->my_archive != NULL
+ && !bfd_is_thin_archive (abfd->my_archive)
+ && ((ufile_ptr) section->filepos + offset + count
+ > arelt_size (abfd))))
{
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
{
#ifdef USE_MMAP
bfd_size_type sz;
- ufile_ptr filesz;
if (count == 0)
return TRUE;
sz = section->rawsize;
else
sz = section->size;
- filesz = bfd_get_file_size (abfd);
- if (offset + count > sz
- || (ufile_ptr) section->filepos + offset + count > filesz
+ if (offset + count < count
+ || offset + count > sz
+ || (abfd->my_archive != NULL
+ && !bfd_is_thin_archive (abfd->my_archive)
+ && ((ufile_ptr) section->filepos + offset + count
+ > arelt_size (abfd)))
|| ! bfd_get_file_window (abfd, section->filepos + offset, count, w,
TRUE))
return FALSE;