This is the mail archive of the binutils@sources.redhat.com 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: [PATCH] bfd robustification (arithmetic overflows on allocationin elf.c and corrupt version section handling)


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



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