[PATCH] Don't call bfd_get_file_size in _bfd_generic_get_section_contents
Alan Modra
amodra@gmail.com
Wed Jun 28 00:54:00 GMT 2017
On Tue, Jun 27, 2017 at 05:53:26AM -0700, H.J. Lu wrote:
> diff --git a/bfd/libbfd.c b/bfd/libbfd.c
> index 0d9de2b..82cffb8 100644
> --- a/bfd/libbfd.c
> +++ b/bfd/libbfd.c
> @@ -788,8 +788,7 @@ _bfd_generic_get_section_contents (bfd *abfd,
> file_ptr offset,
> bfd_size_type count)
> {
> - bfd_size_type sz;
> - ufile_ptr filesz;
> + bfd_size_type sz, end;
> if (count == 0)
> return TRUE;
>
> @@ -812,10 +811,12 @@ _bfd_generic_get_section_contents (bfd *abfd,
> 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)
> + end = offset + count;
It's possible for offset, a file_ptr, to be of a larger integer type
than count, a bfd_size_type. The reverse is also true. For that
reason, don't introduce the temp var "end".
OK without that change.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list