[PATCH] ELF/BFD: Hold the number of internal static relocs in `->reloc_count'
Maciej W. Rozycki
macro@imgtec.com
Fri Jun 2 00:24:00 GMT 2017
On Fri, 2 Jun 2017, Alan Modra wrote:
> > --- binutils.orig/bfd/elflink.c 2017-06-01 21:40:51.679023736 +0100
> > +++ binutils/bfd/elflink.c 2017-06-01 21:44:09.454957776 +0100
> > @@ -2450,8 +2450,7 @@ _bfd_elf_link_read_relocs (bfd *abfd,
> > {
> > bfd_size_type size;
> >
> > - size = o->reloc_count;
> > - size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
> > + size = o->reloc_count * sizeof (Elf_Internal_Rela);
>
> Please cast o->reloc_count to bfd_size_type so that we continue to
> catch some cases of overflow here.
I'll go with:
size = o->reloc_count;
size *= sizeof (Elf_Internal_Rela);
then if you don't mind. I find explicit casts worsen code readability.
Maciej
More information about the Binutils
mailing list