[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: stdbool.h gcc compiler query
On Thu, Aug 08, 2013 at 12:15:20PM +0200, Manuel Bouyer wrote:
> Is stdbool.h really needed here ? AFAIK the build of the elf kernel
> should not rely on host includes, only its own includes.
The original commit 7a549a6aa04 says:
libelf: use C99 bool for booleans
We want to remove uses of "int" because signed integers have
undesirable undefined behaviours on overflow. Malicious compilers can
turn apparently-correct code into code with security vulnerabilities
In this patch we change all the booleans in libelf to C99 bool,
For the one visible libelf boolean in libxc's public interface we
retain the use of int to avoid changing the ABI; libxc converts it to
a bool for consumption by libelf.
It is OK to change all values only ever used as booleans to _Bool
(bool) because conversion from any scalar type to a _Bool works the
same as the boolean test in if() or ?: and is always defined (C99
22.214.171.124). But we do need to check that all these variables really are
only ever used that way. (It is theoretically possible that the old
code truncated some 64-bit values to 32-bit ints which might become
zero depending on the value, which would mean a behavioural change in
this patch, but it seems implausible that treating 0x????????00000000
as false could have been intended.)
This is part of the fix to a security issue, XSA-55.
Signed-off-by: Ian Jackson <ian.jackson%eu.citrix.com@localhost>
Acked-by: George Dunlap <george.dunlap%eu.citrix.com@localhost>
Reviewed-by: Andrew Cooper <andrew.cooper3%citrix.com@localhost>
v3: Use <stdbool.h>'s bool (or _Bool) instead of defining elf_bool.
Split this into a separate patch.
so it is intentional.
I pasted the wrong line in the previous (confused by large MAKEJOBS), but
the compiler flags are the same and boils down to:
gcc -I/usr/include -nostdinc -nostdinc -nostdinc -nostdinc -c libelf-tools.c -o
Yes, there are 4 -nostdinc flags just to make sure...
Main Index |
Thread Index |