[PATCH] bfd robustification (arithmetic overflows on allocation in elf.c and corrupt version section handling)

Jakub Jelinek jakub@redhat.com
Mon Jul 4 19:16:00 GMT 2005


On Mon, Jul 04, 2005 at 04:12:31PM +0100, Nick Clifton wrote:
> But ... have you looked at PR binutils/868 ?  It applies particularly to 
> the use of the realloc() function, but it might be worth considering in 
> the wider context of the changes that you are making.

I think that should be orthogonal to those changes.  So bfd could provide
bfd_realloc, bfd_realloc_or_free, bfd_realloc2 and bfd_realloc2_or_free.

> >+#define HALF_BFD_SIZE_TYPE \
> >+  (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
> 
> Hmm, does this 8 assume that a byte is an 8-bit quantity ?

It does, but I thought we rely on the host char being 8 bit,
only target char can be different.  I could use CHAR_BIT instead,
but nothing in bfd/binutils/ld uses CHAR_BIT ATM, so it would
surprise me if it worked at all with CHAR_BIT != 8.

	Jakub



More information about the Binutils mailing list