Integer Underflow
An integer underflow occurs when an unsigned subtraction result goes below 0 and wraps to a large positive number, potentially causing unexpectedly large allocations or indexes.
Purpose
To analyze unexpected behavior and security vulnerabilities caused by unsigned subtraction underflow.
Mechanism
If an unsigned subtraction yields a negative value it wraps to 2^n - |result|, e.g., 0u - 1 = UINT_MAX. Used in length calculations, this can cause huge allocations or out-of-bounds buffers.
Use cases
- Unsigned arithmetic safety
- Length calculation audit
- Bounds checking