This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pr21665


On Fri, Jun 30, 2017 at 11:03:25AM +0100, Nick Clifton wrote:
> +#define MAX_XMALLOC (1024 * 1024 * 1024 * 2UL) /* 2Gb */
> +  if (datasize > MAX_XMALLOC)
> +    {
> +      non_fatal (_("Reading section %s failed because it is too big (%#lx)"),
> +		 section->name, (unsigned long) datasize);
> +      return;
> +    }
> +
>    data = (bfd_byte *) xmalloc (datasize);

I haven't looked at the bug in detail, but since the testcases are
64-bit, is the problem that on a 32-bit target we're not catching a
size_t overflow?

If so, then

  if (datasize != (size_t) datasize)
    ..

might be a better idea.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]