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: PATCH: Fix buffer overflow in gas


On Tue, May 02, 2006 at 04:36:19PM +0200, Jan Beulich wrote:
> >+static char output_invalid_buf[sizeof (unsigned char) * 2 + 6];
>  
> I'm sorry to say that this, but regardless of actual width of 'char' or 'unsigned char' the above declaration still
> always produces an 8-unit array. What you mean is making room for as many hex digits as an 'unsigned char' can be
> converted to. Without knowing CHAR_BIT (or equivalent) I cannot see how you would be able to derive that. Unfortunately,
> previous work on binutils has shown that one apparently shouldn't make assumptions about the availability of limits.h
> (despite this having been a standard header for at least 15 years), and hence CHAR_BIT is not generally usable here.
> Where needed, I (and apparently others) generally made the assumption that if limits.h isn't available, then the machine
> is supposed to be a 8-bit-bytes one (and bad luck to those perhaps hypothetical machines that aren't and that don't
> provide the header).

I don't want to get too complicated here. We won't have buffer overflow
anymore no matter what CHAR_BIT is. Feel free to improve it.


H.J.


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