...
- Operations on two compile-time constants
- Operations on a variable and 0 (except divison by 0, of course)
- Subtracting any variable from its type's maximum. For instance, any
unsigned int
may safely be subtracted fromUINT_MAX
. - Multiplying any variable by 0 or 1
- Division, as long as the divisor is nonzero.
- Left-shifting 0 by any number.
- Right-shifting any type maximum by any number smaller than the type size. For instance,
UINT_MAX >> x
is valid as long asx < sizeof(unsigned int)
. - Left-shifting 1 by any number smaller than the type size.
Risk Assessment
Integer wrap can lead to buffer overflows and the execution of arbitrary code by an attacker.
...