check_kernel_printf.c: check for signed char versus %02x issue
commit5161229e6b1e8e0e80401e34c6b91761ebfc178d
authorRasmus Villemoes <rv@rasmusvillemoes.dk>
Tue, 8 Dec 2015 22:18:31 +0000 (8 23:18 +0100)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 9 Dec 2015 11:38:13 +0000 (9 14:38 +0300)
tree9eb2d7ae1a24e31c71672ddfe4fb5edd03640901
parentc6ed2cb78adb98e425d0ac90c757a85f27714c08
check_kernel_printf.c: check for signed char versus %02x issue

A common error is to pass a "char" or "signed char" to %02x (or
%.2X or some other variant). This can actually be a security
problem, because a lot of code expects this to produce exactly two
characters of output.

Unfortunately this also produces false positives, since we're
sometimes in arch-specific code on an arch where char is always
unsigned. I think it would be better, even in those cases, to do an
explicit '& 0xff' or equivalently cast the argument to (u8), to help
readers and static checkers not worry and prevent copy-pasting from
introducing an actual bug (and gcc should be able to ignore the mask
if char is indeed unsigned), but evidently not all maintainers agree,
so we'll have to live with these.

Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_kernel_printf.c