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


>+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).

Jan


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