[PATCH] bfd robustification (arithmetic overflows on allocation in elf.c and corrupt version section handling)
Nick Clifton
nickc@redhat.com
Tue Jul 5 09:08:00 GMT 2005
Hi Jakub,
>>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.
Agreed. I just wanted to bring it to your attention since you are
cleaning up code in this area.
>>>+#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.
Yeah me too. I only raised this issue since I have this paranoia about
magic constants appearing in the code.
Cheers
Nick
More information about the Binutils
mailing list